zmiana month na m i poprawka w kolorach paginaci
This commit is contained in:
27
app.py
27
app.py
@@ -1267,17 +1267,38 @@ def favicon():
|
||||
@app.route("/")
|
||||
def main_page():
|
||||
now = datetime.now(timezone.utc)
|
||||
month_str = request.args.get("month") or now.strftime("%Y-%m")
|
||||
|
||||
month_param = request.args.get("month", None) # surowy parametr z URL
|
||||
start = end = None
|
||||
|
||||
if month_str:
|
||||
if month_param in (None, ""):
|
||||
# brak wyboru -> domyślnie aktualny miesiąc
|
||||
month_str = now.strftime("%Y-%m")
|
||||
start = datetime(now.year, now.month, 1, tzinfo=timezone.utc)
|
||||
end = (start + timedelta(days=31)).replace(day=1)
|
||||
|
||||
elif month_param == "all":
|
||||
month_str = "all"
|
||||
start = end = None
|
||||
|
||||
else:
|
||||
month_str = month_param
|
||||
try:
|
||||
year, month = map(int, month_str.split("-"))
|
||||
start = datetime(year, month, 1, tzinfo=timezone.utc)
|
||||
end = (start + timedelta(days=31)).replace(day=1)
|
||||
except:
|
||||
except ValueError:
|
||||
start = end = None
|
||||
|
||||
# dalej normalnie używasz date_filter:
|
||||
def date_filter(query):
|
||||
if start and end:
|
||||
query = query.filter(
|
||||
ShoppingList.created_at >= start,
|
||||
ShoppingList.created_at < end
|
||||
)
|
||||
return query
|
||||
|
||||
def date_filter(query):
|
||||
if start and end:
|
||||
query = query.filter(
|
||||
|
Reference in New Issue
Block a user