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

updating EventsLandingPage sub page types #111

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions cdhweb/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from cdhweb.pages.blocks.image_block import UnsizedImageBlock
from cdhweb.pages.mixin import StandardHeroMixinNoImage
from cdhweb.pages.models import BaseLandingPage, BasePage, ContentPage, LinkPage
from cdhweb.pages.models import LandingPage, BasePage, ContentPage, LinkPage
from cdhweb.people.models import Person


Expand Down Expand Up @@ -415,7 +415,7 @@ class EventsLandingPage(StandardHeroMixinNoImage, Page):
settings_panels = Page.settings_panels

# allow content pages to be added under events for special event series
subpage_types = [Event]
subpage_types = [Event, ContentPage, LandingPage]

def get_upcoming_events_for_semester(self, semester, year):
# Adjust the semester and year to datetime ranges
Expand All @@ -430,19 +430,20 @@ def get_upcoming_events_for_semester(self, semester, year):
end_date = datetime.date(year, 12, 31)
else:
raise ValueError("Invalid semester")

child_pages = self.get_children().live().type(Event)

# Filter events based on start_time within the semester range
return (
self.get_children()
.live()
child_pages
.filter(event__start_time__gte=start_date, event__start_time__lte=end_date)
.order_by("event__start_time")
)

def get_upcoming_events(self):
current_datetime = timezone.now()

child_pages = self.get_children().live()
child_pages = self.get_children().live().type(Event)

# Fetch upcoming events among the child pages
return child_pages.filter(event__start_time__gte=current_datetime).order_by(
Expand Down
1 change: 0 additions & 1 deletion cdhweb/pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ class LandingPage(BaseLandingPage, SidebarNavigationMixin):
BaseLandingPage.settings_panels + SidebarNavigationMixin.settings_panels
)

parent_page_types = ["HomePage", "LandingPage"]
subpage_types = [
"ContentPage",
"people.PeopleLandingPage",
Expand Down
Loading