mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-14 00:32:46 +02:00
feat: improve month_year_picker
This commit is contained in:
@@ -334,19 +334,22 @@ def monthly_summary(request, month: int, year: int):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def month_year_picker(request):
|
def month_year_picker(request):
|
||||||
available_dates = (
|
current_month = int(
|
||||||
Transaction.objects.annotate(
|
request.GET.get("month", timezone.localdate(timezone.now()).month)
|
||||||
month=ExtractMonth("reference_date"), year=ExtractYear("reference_date")
|
|
||||||
)
|
|
||||||
.values("month", "year")
|
|
||||||
.distinct()
|
|
||||||
.order_by("year", "month")
|
|
||||||
)
|
)
|
||||||
|
current_year = int(request.GET.get("year", timezone.localdate(timezone.now()).year))
|
||||||
|
|
||||||
|
available_years = Transaction.objects.dates("reference_date", "year", order="ASC")
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"transactions/fragments/month_year_picker.html",
|
"transactions/fragments/month_year_picker.html",
|
||||||
{"available_dates": available_dates},
|
{
|
||||||
|
"available_years": available_years,
|
||||||
|
"months": range(1, 13),
|
||||||
|
"current_month": current_month,
|
||||||
|
"current_year": current_year,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user