diff --git a/app.py b/app.py index e14a04a..d7d860a 100644 --- a/app.py +++ b/app.py @@ -1748,6 +1748,18 @@ def create_list(): @app.route("/list/") @login_required def view_list(list_id): + + shopping_list = db.session.get(ShoppingList, list_id) + if not shopping_list: + abort(404) + + is_owner = current_user.id == shopping_list.owner_id + if not is_owner: + flash("Nie jesteś właścicielem listy, przekierowano do widoku publicznego.", "warning") + if current_user.is_admin: + flash("W celu modyfikacji listy, przejdź do panelu administracyjnego.", "info") + return redirect(url_for("shared_list", token=shopping_list.share_token)) + shopping_list, items, receipt_files, expenses, total_expense = get_list_details( list_id ) @@ -2541,6 +2553,10 @@ def add_user(): flash("Wypełnij wszystkie pola", "danger") return redirect(url_for("list_users")) + if len(password) < 6: + flash("Hasło musi mieć co najmniej 6 znaków", "danger") + return redirect(url_for("list_users")) + if User.query.filter(func.lower(User.username) == username).first(): flash("Użytkownik o takiej nazwie już istnieje", "warning") return redirect(url_for("list_users")) @@ -2689,6 +2705,12 @@ def admin_receipts(id): flash("Nieprawidłowe ID listy.", "danger") return redirect(url_for("admin_panel")) + total_filesize = ( + db.session.query(func.sum(Receipt.filesize)).scalar() or 0 + ) + + page_filesize = sum(r.filesize or 0 for r in receipts_paginated) + query_string = urlencode({k: v for k, v in request.args.items() if k != "page"}) return render_template( @@ -2701,6 +2723,8 @@ def admin_receipts(id): total_pages=total_pages, id=id, query_string=query_string, + total_filesize=total_filesize, + page_filesize=page_filesize, ) diff --git a/templates/admin/admin_panel.html b/templates/admin/admin_panel.html index f51dd52..90835f5 100644 --- a/templates/admin/admin_panel.html +++ b/templates/admin/admin_panel.html @@ -62,11 +62,11 @@
📈 Średnie tempo tworzenia list:
- + @@ -114,7 +114,7 @@ Miesiąc Rok Całkowite - + @@ -123,21 +123,21 @@ {{ '%.2f'|format(expense_summary.all.month) }} PLN {{ '%.2f'|format(expense_summary.all.year) }} PLN {{ '%.2f'|format(expense_summary.all.total) }} PLN - + Aktywne {{ '%.2f'|format(expense_summary.active.month) }} PLN {{ '%.2f'|format(expense_summary.active.year) }} PLN {{ '%.2f'|format(expense_summary.active.total) }} PLN - + Archiwalne {{ '%.2f'|format(expense_summary.archived.month) }} PLN {{ '%.2f'|format(expense_summary.archived.year) }} PLN {{ '%.2f'|format(expense_summary.archived.total) }} PLN - + Wygasłe @@ -156,59 +156,59 @@ - - {# panel wyboru miesiąca zawsze widoczny #} -
- - {# LEWA STRONA — przyciski ← → TYLKO gdy nie show_all #} -
- {% if not show_all %} - {% set current_date = now.replace(day=1) %} - {% set prev_month = (current_date - timedelta(days=1)).strftime('%Y-%m') %} - {% set next_month = (current_date + timedelta(days=31)).replace(day=1).strftime('%Y-%m') %} - - {% if prev_month in month_options %} - - ← {{ prev_month }} - - {% else %} - - {% endif %} - - {% if next_month in month_options %} - - {{ next_month }} → - - {% else %} - - {% endif %} - {% else %} - {# Tryb wszystkie miesiące — możemy pokazać skrót do bieżącego miesiąca #} - - 📅 Przejdź do bieżącego miesiąca - - {% endif %} -
- - {# PRAWA STRONA — picker miesięcy zawsze widoczny #} -
-
- 📅 - -
-
-
-
+ + {# panel wyboru miesiąca zawsze widoczny #} +
+ + {# LEWA STRONA — przyciski ← → TYLKO gdy nie show_all #} +
+ {% if not show_all %} + {% set current_date = now.replace(day=1) %} + {% set prev_month = (current_date - timedelta(days=1)).strftime('%Y-%m') %} + {% set next_month = (current_date + timedelta(days=31)).replace(day=1).strftime('%Y-%m') %} + + {% if prev_month in month_options %} + + ← {{ prev_month }} + + {% else %} + + {% endif %} + + {% if next_month in month_options %} + + {{ next_month }} → + + {% else %} + + {% endif %} + {% else %} + {# Tryb wszystkie miesiące — możemy pokazać skrót do bieżącego miesiąca #} + + 📅 Przejdź do bieżącego miesiąca + + {% endif %} +
+ + {# PRAWA STRONA — picker miesięcy zawsze widoczny #} +
+
+ 📅 + +
+
+
+

📄 Listy zakupowe {% if show_all %} diff --git a/templates/admin/list_products.html b/templates/admin/list_products.html index 3871da0..6637b75 100644 --- a/templates/admin/list_products.html +++ b/templates/admin/list_products.html @@ -132,6 +132,7 @@

+
diff --git a/templates/admin/mass_edit_categories.html b/templates/admin/mass_edit_categories.html index bd68283..6daab00 100644 --- a/templates/admin/mass_edit_categories.html +++ b/templates/admin/mass_edit_categories.html @@ -80,18 +80,16 @@ {% endif %} -
- -
- +
+
- +
diff --git a/templates/admin/receipts.html b/templates/admin/receipts.html index 7b9bbd7..9198390 100644 --- a/templates/admin/receipts.html +++ b/templates/admin/receipts.html @@ -3,7 +3,35 @@ {% block content %}
-

📸 Wszystkie paragony

+

+ 📸 {% if id == 'all' %}Wszystkie paragony{% else %}Paragony dla listy #{{ id }}{% endif %} +

+ +

+ {% if id == 'all' %} + Rozmiar plików tej strony: + {% else %} + Rozmiar plików listy #{{ id }}: + {% endif %} + + {% if page_filesize >= 1024*1024 %} + {{ (page_filesize / 1024 / 1024) | round(2) }} MB + {% else %} + {{ (page_filesize / 1024) | round(1) }} kB + {% endif %} + + | + Łącznie: + + {% if total_filesize >= 1024*1024 %} + {{ (total_filesize / 1024 / 1024) | round(2) }} MB + {% else %} + {{ (total_filesize / 1024) | round(1) }} kB + {% endif %} + +

+ +
+
@@ -137,8 +166,10 @@