Add meal v2 flow and user timezone support

Introduces a new add_meal_v2 blueprint with barcode scanning, item search, and improved meal logging UI. Adds user timezone support: login form now captures timezone, User model and database schema updated, and timezone is set on login. Refactors templates and forms to support these changes, and removes the old login template.
This commit is contained in:
2025-08-14 06:08:17 +02:00
parent 7ff345d3a2
commit d78f48710e
14 changed files with 503 additions and 43 deletions

View File

@@ -4,6 +4,7 @@ from application import db
from typing import Optional
from forms import FoodItemForm
from datetime import datetime, timezone, date
from application.utils import is_valid_timezone
class User(UserMixin, db.Model):
@@ -11,6 +12,7 @@ class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(150), unique=True, nullable=False)
password = db.Column(db.String, nullable=False)
timezone = db.Column(db.String(64), nullable=False, default="UTC")
is_admin = db.Column(db.Boolean, nullable=False, default=False)
must_change_password = db.Column(db.Boolean, nullable=False, default=False)
@@ -39,6 +41,10 @@ class User(UserMixin, db.Model):
def set_pw_change(self, change: bool) -> None:
self.must_change_password = change
def set_timezone(self, tz: str) -> None:
if is_valid_timezone(tz):
self.timezone = tz
class Unit(db.Model):
__tablename__ = "unit"