zmiana month na m i poprawka w kolorach paginaci

This commit is contained in:
Mateusz Gruszczyński
2025-08-13 14:46:46 +02:00
parent ea5f9a3f27
commit 01fa938a27
2 changed files with 40 additions and 29 deletions

36
app.py
View File

@@ -939,6 +939,25 @@ def save_pdf_as_webp(file, path):
raise ValueError(f"Błąd podczas przetwarzania PDF: {e}")
def get_active_months_query(visible_lists_query=None):
if db.engine.name == "sqlite":
month_col = func.strftime('%Y-%m', ShoppingList.created_at)
else:
month_col = func.to_char(ShoppingList.created_at, 'YYYY-MM')
query = db.session.query(month_col.label("month"))
if visible_lists_query is not None:
query = query.select_from(visible_lists_query.subquery())
active_months = (
query.filter(ShoppingList.created_at != None)
.distinct()
.order_by("month")
.all()
)
return [row.month for row in active_months]
############# OCR ###########################
@@ -1317,6 +1336,7 @@ def main_page():
.order_by(ShoppingList.created_at.desc())
.all()
)
month_options = get_active_months_query(visible_lists_query)
all_lists = user_lists + public_lists + archived_lists
all_ids = [l.id for l in all_lists]
@@ -1378,6 +1398,7 @@ def main_page():
archived_lists=archived_lists,
now=now,
timedelta=timedelta,
month_options=month_options
)
@@ -2171,20 +2192,7 @@ def admin_panel():
all_lists = base_query.all()
# tylko listy z danych miesięcy
if db.engine.name == "sqlite":
month_col = func.strftime('%Y-%m', ShoppingList.created_at)
else:
month_col = func.to_char(ShoppingList.created_at, 'YYYY-MM')
active_months = (
db.session.query(month_col.label("month"))
.filter(ShoppingList.created_at != None)
.distinct()
.order_by("month") # bez min()
.all()
)
month_options = [row.month for row in active_months]
month_options = get_active_months_query()
all_ids = [l.id for l in all_lists]