mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-29 19:00:00 +00:00
Introduces a user dashboard route and template, moving dashboard logic to a user blueprint. FoodItem now has an owner_id field and a unique constraint on (barcode, owner_id), with relationships set up in the User model. Updates food item creation to associate with the current user, and adds a utility script for dropping a temporary table.
25 lines
615 B
Python
25 lines
615 B
Python
from application import db, app
|
|
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",
|
|
owner_id=0,
|
|
energy=430,
|
|
fats=19,
|
|
carbs=59,
|
|
protein=5.5,
|
|
saturated_fats=10,
|
|
sugar=35,
|
|
barcode=2278012003502,
|
|
)
|
|
)
|
|
|
|
db.session.commit()
|