diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..8d451fc --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +# CLAUDE.md + +## Conventions + +- Database objects (tables, columns, indexes, constraints, etc.) must be named in English, using snake_case (all lowercase, words separated by underscores, e.g. `user_account`, `created_at`). diff --git a/__pycache__/app.cpython-312.pyc b/__pycache__/app.cpython-312.pyc new file mode 100644 index 0000000..140bd9d Binary files /dev/null and b/__pycache__/app.cpython-312.pyc differ diff --git a/__pycache__/config.cpython-312.pyc b/__pycache__/config.cpython-312.pyc new file mode 100644 index 0000000..7d02391 Binary files /dev/null and b/__pycache__/config.cpython-312.pyc differ diff --git a/__pycache__/models.cpython-312.pyc b/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000..c0cc737 Binary files /dev/null and b/__pycache__/models.cpython-312.pyc differ diff --git a/app.py b/app.py index e5d155f..2b8079a 100644 --- a/app.py +++ b/app.py @@ -10,7 +10,7 @@ from flask_login import ( ) from config import Config -from models import db, User, Fahrt, VERKEHRSMITTEL_OPTIONEN +from models import db, User, Trip, VERKEHRSMITTEL_OPTIONEN login_manager = LoginManager() login_manager.login_view = "login" @@ -91,8 +91,8 @@ def register_routes(app): @login_required def dashboard(): fahrten = ( - Fahrt.query.filter_by(user_id=current_user.id) - .order_by(Fahrt.datum.desc()) + Trip.query.filter_by(user_id=current_user.id) + .order_by(Trip.trip_date.desc()) .all() ) return render_template("dashboard.html", fahrten=fahrten) @@ -101,15 +101,15 @@ def register_routes(app): @login_required def neue_fahrt(): if request.method == "POST": - fahrt = Fahrt( + fahrt = Trip( user_id=current_user.id, - verkehrsmittel=request.form["verkehrsmittel"], - linie=request.form.get("linie", "").strip(), - von=request.form["von"].strip(), - nach=request.form["nach"].strip(), - datum=request.form.get("datum") or date.today(), - bewertung=int(request.form["bewertung"]), - kommentar=request.form.get("kommentar", "").strip(), + transport_mode=request.form["transport_mode"], + line=request.form.get("line", "").strip(), + origin=request.form["origin"].strip(), + destination=request.form["destination"].strip(), + trip_date=request.form.get("trip_date") or date.today(), + rating=int(request.form["rating"]), + comment=request.form.get("comment", "").strip(), ) db.session.add(fahrt) db.session.commit() @@ -125,7 +125,7 @@ def register_routes(app): @app.route("/fahrt//loeschen", methods=["POST"]) @login_required def fahrt_loeschen(fahrt_id): - fahrt = Fahrt.query.get_or_404(fahrt_id) + fahrt = Trip.query.get_or_404(fahrt_id) if fahrt.user_id != current_user.id: flash("Nicht erlaubt.", "error") return redirect(url_for("dashboard")) diff --git a/models.py b/models.py index 4b72ae5..4e42dab 100644 --- a/models.py +++ b/models.py @@ -14,8 +14,8 @@ class User(UserMixin, db.Model): email = db.Column(db.String(120), unique=True, nullable=False, index=True) password_hash = db.Column(db.String(255), nullable=False) - fahrten = db.relationship( - "Fahrt", backref="user", lazy=True, cascade="all, delete-orphan" + trips = db.relationship( + "Trip", backref="user", lazy=True, cascade="all, delete-orphan" ) def set_password(self, password: str) -> None: @@ -36,18 +36,18 @@ VERKEHRSMITTEL_OPTIONEN = [ ] -class Fahrt(db.Model): - __tablename__ = "fahrten" +class Trip(db.Model): + __tablename__ = "trips" id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=False, index=True) - verkehrsmittel = db.Column(db.String(50), nullable=False) - linie = db.Column(db.String(50)) - von = db.Column(db.String(120), nullable=False) - nach = db.Column(db.String(120), nullable=False) - datum = db.Column(db.Date, nullable=False, default=date.today) - bewertung = db.Column(db.Integer, nullable=False) # 1-5 - kommentar = db.Column(db.Text) + transport_mode = db.Column(db.String(50), nullable=False) + line = db.Column(db.String(50)) + origin = db.Column(db.String(120), nullable=False) + destination = db.Column(db.String(120), nullable=False) + trip_date = db.Column(db.Date, nullable=False, default=date.today) + rating = db.Column(db.Integer, nullable=False) # 1-5 + comment = db.Column(db.Text) - erstellt_am = db.Column(db.DateTime, server_default=db.func.now()) + created_at = db.Column(db.DateTime, server_default=db.func.now()) diff --git a/templates/add_entry.html b/templates/add_entry.html index 8bc214d..045be49 100644 --- a/templates/add_entry.html +++ b/templates/add_entry.html @@ -5,8 +5,8 @@

Neue Fahrt erfassen

- - {% for option in verkehrsmittel_optionen %} {% endfor %} @@ -14,28 +14,28 @@
- - + +
- - + +
- - + +
- - + +
- - @@ -45,8 +45,8 @@
- - + +
diff --git a/templates/dashboard.html b/templates/dashboard.html index 8a80106..e48ce38 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -23,19 +23,19 @@ {% for f in fahrten %} - {{ f.datum.strftime("%d.%m.%Y") }} - {{ f.verkehrsmittel }} - {{ f.linie or "–" }} - {{ f.von }} → {{ f.nach }} - {{ "★" * f.bewertung }}{{ "☆" * (5 - f.bewertung) }} + {{ f.trip_date.strftime("%d.%m.%Y") }} + {{ f.transport_mode }} + {{ f.line or "–" }} + {{ f.origin }} → {{ f.destination }} + {{ "★" * f.rating }}{{ "☆" * (5 - f.rating) }}
- {% if f.kommentar %} - {{ f.kommentar }} + {% if f.comment %} + {{ f.comment }} {% endif %} {% endfor %}