Add admin check and update FoodItems model

Introduced an admin_required check for all admin routes using Flask-Login's current_user. Updated the FoodItems model to use per-100g nutritional fields and removed unit relationships. Seed script now creates both admin and regular user accounts.
This commit is contained in:
2025-06-27 17:23:54 +02:00
parent 1b428b0bda
commit a5312d7ad0
3 changed files with 28 additions and 15 deletions

View File

@@ -1,7 +1,11 @@
from application import db, app
from models import User
from models import User, FoodItems
with app.app_context():
User.query.delete()
db.session.add(User("admin", "admin"))
db.session.add(User(username="admin", password="admin", is_admin=True))
db.session.add(User(username="user", password="user", is_admin=False))
db.session.commit()