mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-29 19:00:00 +00:00
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:
8
seed.py
8
seed.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user