Refactor food item model and add barcode scanner page

Renamed FoodItems to FoodItem and Units to Unit in models.py, updated related imports and usage throughout the codebase. Added a barcode scanner test page using ZXing in the admin section. Improved food_items.html to display nutritional information in a table. Registered the admin blueprint in app.py and cleaned up blueprint registration in __init__.py. Updated seed.py to use the new FoodItem model.
This commit is contained in:
2025-06-28 12:53:27 +02:00
parent a5312d7ad0
commit d5e8c3fa94
8 changed files with 145 additions and 19 deletions

17
seed.py
View File

@@ -1,11 +1,22 @@
from application import db, app
from models import User, FoodItems
from models import User, FoodItem
with app.app_context():
User.query.delete()
db.session.add(User(username="admin", password="admin", is_admin=True))
db.session.add(User(username="user", password="user", is_admin=False))
FoodItem.query.delete()
db.session.add(
FoodItem(
name="AH Matcha cookie",
energy=430,
fats=19,
carbs=59,
protein=5.5,
saturated_fats=10,
sugar=35,
)
)
db.session.commit()