Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad678df2ce | ||
|
|
8b70ed1550 | ||
|
|
05128b5156 | ||
|
|
8e8e03d4e0 | ||
|
|
ca6c31b91d | ||
|
|
8c6c4ff253 | ||
|
|
6b84441d75 | ||
|
|
61ee4ba1f8 | ||
|
|
396b4636f3 | ||
|
|
ce8857f92b | ||
|
|
85faf8aa5b |
No files matched your search
@@ -1,14 +1,21 @@
|
||||
# Tandoor-Shoppinglist
|
||||
# Tandur
|
||||
|
||||
Eine Website, die sich von einer selber gehosteten Tandoor-Instanz die Shoppinglist Einträge nimmt, und als Shoppinglist anzeigt.
|
||||
|
||||
<div style="border-left: 4px solid #da3633; background-color: rgba(218, 54, 51, 0.1); padding: 12px 16px; border-radius: 0 6px 6px 0; margin: 16px 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;">
|
||||
<div style="font-weight: 600; color: #f85149; margin-bottom: 4px; display: flex; align-items: center; gap: 8px;">
|
||||
<span>⚠️</span> <strong>Just created</strong>
|
||||
</div>
|
||||
<div style="color: #c9d1d9; font-size: 14px;">
|
||||
This Repository was just created. It isnt finished and under heavy construction. So this Service is unstable!
|
||||
</div>
|
||||
</div>
|
||||
|
||||
## Inhalt
|
||||
- TODO
|
||||
- Fsetlegungen
|
||||
|
||||
|
||||
|
||||
|
||||
- Festlegungen
|
||||
- Ablauf
|
||||
- Installation
|
||||
|
||||
|
||||
## TODO
|
||||
@@ -17,6 +24,41 @@ Eine Website, die sich von einer selber gehosteten Tandoor-Instanz die Shoppingl
|
||||
- [ ] Next.js -> Frontend ?
|
||||
- [ ] Python -> Backend
|
||||
- [ ] Implementieren
|
||||
- [ ] README in English and German
|
||||
|
||||
## Festlegungen
|
||||
*Hier muss noch beschrieben werden, wie genau das gemacht wird.*
|
||||
- Database: SQLite3 mit sqlmodel
|
||||
- API FastAPI
|
||||
- Jinja
|
||||
- TailwindCSS + Alpine.js
|
||||
???
|
||||
|
||||
## Ablauf
|
||||
- Data fetch from Tandoor via APIs
|
||||
- Data fetch from Database
|
||||
- View on Website and edit
|
||||
- Order vie Mail
|
||||
- CSV download *optional
|
||||
|
||||
## Installation
|
||||
### Bare metal
|
||||
##### Linux
|
||||
**Download and Setup**
|
||||
|
||||
```
|
||||
git clone https://git.schamagusa.de/rudi/Tandur.git
|
||||
cd Tandur
|
||||
|
||||
source .venv/bin/activate
|
||||
#source .venv/bin/activate.fish #if you are using fish-shell
|
||||
|
||||
pip install --no-cache-dir -r requirements.txt
|
||||
```
|
||||
##### Run
|
||||
```
|
||||
uvicorn main:app
|
||||
```
|
||||
### Docker Compose (recomended)
|
||||
#TODO
|
||||
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
from typing import Optional
|
||||
from sqlmodel import Field, SQLModel, create_engine, Session
|
||||
|
||||
# 1. Das Datenmodell (Tabelle in der DB)
|
||||
class ShoppingItem(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str
|
||||
menge: int = Field(default=1)
|
||||
gekauft: bool = Field(default=False)
|
||||
|
||||
# 2. Die SQLite-Verbindung
|
||||
# check_same_thread=False ist zwingend nötig für FastAPI + SQLite
|
||||
sqlite_url = "sqlite:///tandur.db"
|
||||
engine = create_engine(sqlite_url, connect_args={"check_same_thread": False})
|
||||
|
||||
# 3. Funktion zum Erstellen der Tabellen
|
||||
def create_db_and_tables():
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
# 4. Session-Generator für die Routen
|
||||
def get_session():
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
@@ -1,19 +1,9 @@
|
||||
from contextlib import asynccontextmanager
|
||||
from fastapi import FastAPI, Request, Depends
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from database import create_db_and_tables, get_session, ShoppingItem
|
||||
from sqlmodel import Session
|
||||
|
||||
# Wird beim Starten des Servers exakt einmal ausgeführt
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
create_db_and_tables()
|
||||
yield
|
||||
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
app = FastAPI()
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
@app.get("/")
|
||||
async def home(request: Request, session: Session = Depends(get_session)):
|
||||
# Hier können wir bald Daten aus der DB laden
|
||||
async def home(request: Request):
|
||||
return templates.TemplateResponse(request=request, name="index.html")
|
||||
Reference in new issue
Block a user