zmiana month na m i poprawka w kolorach paginaci
This commit is contained in:
36
app.py
36
app.py
@@ -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]
|
||||
|
||||
|
Reference in New Issue
Block a user