Files
cal_counter/application/admin/routes.py
Stef d5e8c3fa94 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.
2025-06-28 12:53:27 +02:00

28 lines
609 B
Python

from flask import Blueprint, render_template, abort
from flask_login import current_user
from models import FoodItem
admin_bp = Blueprint(
"admin",
__name__,
url_prefix="/admin",
template_folder="templates",
)
@admin_bp.before_request
def admin_required():
if not current_user.is_admin:
abort(403)
@admin_bp.route("/food_items", methods=["GET"])
def food_items():
items = FoodItem.query.all()
return render_template("food_items.html", items=items)
@admin_bp.route("/barcode_test", methods=["GET"])
def barcode_test():
return render_template("barcode_test.html")