From 18fa0fdb2d3ecc966fd4c034d5fe56b0b2bf9543 Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 11 Aug 2025 16:56:40 +0200 Subject: [PATCH] Remove admin food item and barcode test routes and templates Deleted the /food_items and /barcode_test routes from admin, along with their associated templates and the delete_food functionality. This streamlines the admin blueprint by removing unused or deprecated features. --- application/admin/routes.py | 25 +-------- application/admin/templates/barcode_test.html | 55 ------------------- application/admin/templates/food_items.html | 47 ---------------- 3 files changed, 1 insertion(+), 126 deletions(-) delete mode 100644 application/admin/templates/barcode_test.html delete mode 100644 application/admin/templates/food_items.html diff --git a/application/admin/routes.py b/application/admin/routes.py index b006dad..30adb6d 100644 --- a/application/admin/routes.py +++ b/application/admin/routes.py @@ -1,7 +1,5 @@ -from flask import Blueprint, render_template, abort, redirect, url_for +from flask import Blueprint, abort from flask_login import current_user -from models import FoodItem -from application import db admin_bp = Blueprint( "admin", @@ -15,24 +13,3 @@ admin_bp = Blueprint( 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") - - -@admin_bp.route("/delete_food/", methods=["POST"]) -def delete_food(id): - item = FoodItem.query.get(id) - if item: - if item.owner_id == current_user.id: - db.session.delete(item) - db.session.commit() - return redirect(url_for("admin.food_items")) diff --git a/application/admin/templates/barcode_test.html b/application/admin/templates/barcode_test.html deleted file mode 100644 index 63353f2..0000000 --- a/application/admin/templates/barcode_test.html +++ /dev/null @@ -1,55 +0,0 @@ -{% extends "base.html" %} -{% block title %} -ZXing Barcode Scanner -{% endblock %} - -{% block content %} -
-

📷 ZXing Barcode Scanner

- -
- -
- -
- - -
- -
-
Result:
-

-
-
- - -{% endblock %} \ No newline at end of file diff --git a/application/admin/templates/food_items.html b/application/admin/templates/food_items.html deleted file mode 100644 index eaa40a0..0000000 --- a/application/admin/templates/food_items.html +++ /dev/null @@ -1,47 +0,0 @@ -{% extends "base.html" %} - -{% block title %} -Food Nutritional Info -{% endblock %} - -{% block content %} -
-

Food Nutritional Information (per 100g/100ml)

-
- - - - - - - - - - - - - - - {% for food in items %} - - - - - - - - - - - {% endfor %} - -
NameEnergy (kcal)fat (g)Saturated fat (g)Sugars (g)Carbs (g)Protein (g)Actions
{{ food.name }}{{ food.energy_100 }}{{ food.fat_100 }}{{ food.saturated_fat_100 }}{{ food.sugar_100 }}{{ food.carbs_100 }}{{ food.protein_100 }} -
- -
-
-
-
- -{% endblock%} \ No newline at end of file