From 930f11ef6deaac0e2b5983c9194d27e1e1c98144 Mon Sep 17 00:00:00 2001 From: sarahframe Date: Wed, 21 Aug 2024 10:41:20 +1200 Subject: [PATCH] fix by semester path --- cdhweb/events/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cdhweb/events/models.py b/cdhweb/events/models.py index 92448cb0..7b01a3f0 100644 --- a/cdhweb/events/models.py +++ b/cdhweb/events/models.py @@ -17,7 +17,7 @@ from taggit.managers import TaggableManager from taggit.models import TaggedItemBase from wagtail.admin.panels import FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel -from wagtail.contrib.routable_page.models import RoutablePageMixin, path +from wagtail.contrib.routable_page.models import RoutablePageMixin, path, re_path from wagtail.fields import RichTextField from wagtail.models import Page, PageManager, PageQuerySet from wagtail.search import index @@ -433,9 +433,9 @@ def get_context(self, request, semester=None, year=None): context["date_list"] = self.get_semester_date_list() return context - @path("-/", name="by-semester") + @re_path(r"^(?Pspring|summer|fall)-(?P\d{4})", name="by-semester") def by_semester(self, request, semester=None, year=None): - context = self.get_context(request, semester=semester, year=year) + context = self.get_context(request, semester=semester, year=int(year)) return self.render(request, context_overrides=context) @path("///", name="dated_child") @@ -464,7 +464,7 @@ def get_upcoming_events_for_semester(self, semester, year): start_date = datetime.date(year, 9, 1) end_date = datetime.date(year, 12, 31) else: - raise ValueError("Invalid semester") + raise ValueError(f"Invalid semester: {semester}") child_pages = self.get_children().live().type(Event) # Filter events based on start_time within the semester range