Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix by semester path #172

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cdhweb/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -433,9 +433,9 @@ def get_context(self, request, semester=None, year=None):
context["date_list"] = self.get_semester_date_list()
return context

@path("<semester>-<int:year>/", name="by-semester")
@re_path(r"^(?P<semester>spring|summer|fall)-(?P<year>\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("<int:year>/<int:month>/<slug:slug>/", name="dated_child")
Expand Down Expand Up @@ -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
Expand Down
Loading