|
1 | | -from datetime import date |
| 1 | +from datetime import date, datetime |
2 | 2 | from typing import Any, cast |
3 | 3 |
|
4 | 4 | from django.db.models import QuerySet |
@@ -88,13 +88,20 @@ def htmx_schedule(self, request: HttpRequest) -> HttpResponse: |
88 | 88 | instructor: Instructor | None = getattr(request.user, "instructor", None) |
89 | 89 | show_action: bool = request.GET.get("a") == "1" |
90 | 90 | today: date = timezone.now().date() |
| 91 | + month: date = (datetime.strptime(mth, "%Y-%m-%d").date() |
| 92 | + if (mth := request.GET.get("m", "")) else timezone.now().date() |
| 93 | + ) |
91 | 94 |
|
92 | 95 | dates: list[dict[str, Any]] = [] |
93 | 96 | if instructor: |
94 | | - dates = self.schedule__get_calendar_dates(instructor) |
| 97 | + dates = self.schedule__get_calendar_dates(instructor, month) |
95 | 98 | dates = self.schedule__add_date_events(dates, instructor) |
| 99 | + next_month: date = self.schedule__get_first_of_next_month(month) |
| 100 | + |
| 101 | + scroll_to_top: bool = request.GET.get("st") == "1" |
| 102 | + template: str = "schedule" if show_action else "calendar" |
96 | 103 |
|
97 | | - return render(request, "agojin/instructor/schedule.html", locals()) |
| 104 | + return render(request, f"agojin/instructor/{template}.html", locals()) |
98 | 105 |
|
99 | 106 | def htmx_stats(self, request: HttpRequest) -> HttpResponse: |
100 | 107 | instructor: Instructor | None = getattr(request.user, "instructor", None) |
|
0 commit comments