mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-30 03:10:00 +00:00
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.
28 lines
609 B
Python
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")
|