diff --git a/community/models.py b/community/models.py index da4d0bcf3..6e823ad67 100644 --- a/community/models.py +++ b/community/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.http import HttpRequest from wagtail import blocks as wagtail_blocks from wagtail.admin.panels import FieldPanel, PageChooserPanel from wagtail.fields import RichTextField, StreamField @@ -122,6 +123,23 @@ class OnlineWorshipIndexPage(Page): template = "community/online_worship_index_page.html" + def get_context( + self, + request: HttpRequest, + *args: tuple, + **kwargs: dict, + ) -> dict: + context = super().get_context(request, *args, **kwargs) + + # Get all live OnlineWorship objects sorted by title + online_worship_meetings = OnlineWorship.objects.live().order_by( + "title", + ) + + context["online_worship_meetings"] = online_worship_meetings + + return context + class CommunityDirectory(Page): description = RichTextField(blank=True) diff --git a/community/templates/community/online_worship_index_page.html b/community/templates/community/online_worship_index_page.html index 3ac88445c..77212a9a3 100644 --- a/community/templates/community/online_worship_index_page.html +++ b/community/templates/community/online_worship_index_page.html @@ -11,53 +11,53 @@

{{ page.intro | richtext }} - {% for online_worship in self.get_children|dictsort:"title" %} + {% for online_worship in online_worship_meetings %}

{{ online_worship.title }}

- {% if online_worship.specific.times_of_worship %} + {% if online_worship.times_of_worship %}

Times of worship:  - {{ online_worship.specific.times_of_worship | richtext }} + {{ online_worship.times_of_worship | richtext }}

{% endif %} - {% if online_worship.specific.hosted_by %} + {% if online_worship.hosted_by %}

Hosted by:  - {{ online_worship.specific.hosted_by }} + {{ online_worship.hosted_by }}

{% endif %} - {% if online_worship.specific.online_worship_day %} + {% if online_worship.online_worship_day %}

Online worship day:  - {{ online_worship.specific.online_worship_day }} + {{ online_worship.online_worship_day }}

{% endif %} - {% if online_worship.specific.online_worship_time %} + {% if online_worship.online_worship_time %}

Online worship time:  - {{ online_worship.specific.online_worship_time }} - {% if online_worship.specific.online_worship_timezone %} - ({{ online_worship.specific.online_worship_timezone }}) + {{ online_worship.online_worship_time }} + {% if online_worship.online_worship_timezone %} + ({{ online_worship.online_worship_timezone }}) {% endif %}

{% endif %} - {% if online_worship.specific.online_worship_url %} + {% if online_worship.online_worship_url %}

Online worship URL:  - {{ online_worship.specific.online_worship_url }} + {{ online_worship.online_worship_url }}

{% endif %} - {% if online_worship.specific.online_worship_notes %} + {% if online_worship.online_worship_notes %}

Online worship notes:  - {{ online_worship.specific.online_worship_notes }} + {{ online_worship.online_worship_notes }}

{% endif %} View details diff --git a/core/urls.py b/core/urls.py index f162db766..a5b1dc942 100644 --- a/core/urls.py +++ b/core/urls.py @@ -8,9 +8,8 @@ from wagtail.admin import urls as wagtailadmin_urls from wagtail.contrib.sitemaps.views import sitemap from wagtail.documents import urls as wagtaildocs_urls +import debug_toolbar -if settings.DEBUG: - import debug_toolbar # TODO: Change this line to send verification emails when registering users # Note: this will require two activation email tempates (subject and body) # from django_registration.backends.activation.views import RegistrationView @@ -50,5 +49,14 @@ if settings.DEBUG: # Serve static and media files from development server urlpatterns += staticfiles_urlpatterns() - urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) - urlpatterns += [path("__debug__/", include(debug_toolbar.urls))] # type: ignore + urlpatterns += static( + settings.MEDIA_URL, + document_root=settings.MEDIA_ROOT, + ) + urlpatterns.insert( + 0, + path( + "__debug__/", + include(debug_toolbar.urls), + ), + )