From cc988d593407a3ae475be268f99284450c42d2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Fri, 15 Aug 2025 15:47:32 +0200 Subject: [PATCH] usuniecie zbednego kodu i poprawki --- app.py | 38 ++++-------------------------- templates/admin/list_products.html | 15 +++--------- 2 files changed, 7 insertions(+), 46 deletions(-) diff --git a/app.py b/app.py index 0a35683..70ab19f 100644 --- a/app.py +++ b/app.py @@ -2835,7 +2835,7 @@ def edit_list(list_id): @admin_required def list_products(): page = request.args.get("page", 1, type=int) - per_page = request.args.get("per_page", 125, type=int) + per_page = request.args.get("per_page", 100, type=int) per_page = max(1, min(per_page, 300)) all_items = ( @@ -2878,40 +2878,10 @@ def list_products(): if name in all_suggestions_dict } orphan_suggestions = [ - s - for name, s in all_suggestions_dict.items() + s for name, s in all_suggestions_dict.items() if name not in used_suggestion_names ] - orphan_names_lower = {(s.name or "").strip().lower() for s in orphan_suggestions} - if orphan_names_lower: - items_for_orphans = ( - Item.query.filter(func.lower(Item.name).in_(orphan_names_lower)) - .filter(Item.added_by.isnot(None)) - .options(joinedload(Item.added_by_user)) - .order_by(Item.id.desc()) - .all() - ) - name_to_user = {} - for it in items_for_orphans: - key = (it.name or "").strip().lower() - if key not in name_to_user and it.added_by: - name_to_user[key] = it.added_by - suggestion_added_by_map = { - s.id: name_to_user.get((s.name or "").strip().lower()) - for s in orphan_suggestions - } - missing_user_ids = { - uid - for uid in suggestion_added_by_map.values() - if uid and uid not in users_dict - } - if missing_user_ids: - extra_users = User.query.filter(User.id.in_(missing_user_ids)).all() - users_dict.update({u.id: u.username for u in extra_users}) - else: - suggestion_added_by_map = {} - query_string = urlencode({k: v for k, v in request.args.items() if k != "page"}) return render_template( @@ -2920,15 +2890,15 @@ def list_products(): users_dict=users_dict, suggestions_dict=suggestions_dict, orphan_suggestions=orphan_suggestions, - suggestion_added_by_map=suggestion_added_by_map, page=page, per_page=per_page, total_pages=total_pages, query_string=query_string, - total_items=total_items, + total_items=total_items ) + @app.route("/admin/sync_suggestion/", methods=["POST"]) @login_required def sync_suggestion_ajax(item_id): diff --git a/templates/admin/list_products.html b/templates/admin/list_products.html index 785fc4e..e955091 100644 --- a/templates/admin/list_products.html +++ b/templates/admin/list_products.html @@ -72,7 +72,6 @@ ID Nazwa - Dodany przez Akcje @@ -82,14 +81,6 @@ {{ suggestion.id }} {{ suggestion.name }} - - {% set uid = suggestion_added_by_map.get(suggestion.id) %} - {% if uid and users_dict.get(uid) %} - 👤 {{ users_dict[uid] }} ({{ uid }}) - {% else %} - - - {% endif %} - @@ -112,9 +103,9 @@