Skip to content

Commit

Permalink
Merge pull request #156 from springload/fix/add-ical
Browse files Browse the repository at this point in the history
Add ical link back to events
  • Loading branch information
haydngreatnews authored Aug 5, 2024
2 parents 4bc1d21 + e76ff72 commit e0d1f41
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cdhweb/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def clean(self):
def get_ical_url(self):
"""URL to download this event as a .ics (iCal) file."""
return reverse(
"events:ical",
"event-ical",
kwargs={
"year": self.start_time.year,
# force two-digit month
Expand Down
5 changes: 5 additions & 0 deletions cdhweb/static_src/global/components/event-hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ Event hero. Similar to standard hero. Key differences:
margin: 16px 0 0;
}

.event-hero__add-to-calendar {
margin: 4px 0 16px;
font-size: px2rem(14);
}

.event-hero__location {
font-weight: bold;
margin: 8px 0 0;
Expand Down
6 changes: 6 additions & 0 deletions cdhweb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from cdhweb.context_processors import favicon_path
from cdhweb.pages.views import OpenSearchDescriptionView, SiteSearchView
from cdhweb.events.views import EventIcalView

admin.autodiscover()

Expand Down Expand Up @@ -60,6 +61,11 @@
{"sitemaps": sitemaps},
name="django.contrib.sitemaps.views.sitemap",
),
re_path(
r"^events/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[\w-]+).ics$",
EventIcalView.as_view(),
name="event-ical",
),
# wagtail paths
path("cms/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
Expand Down
11 changes: 7 additions & 4 deletions templates/includes/event_hero.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ <h1>{{ self.title}}</h1>
<p class="event-hero__date">
{# Display date differently depending on if it spans multiple days #}
{% if self.start_time.date == self.end_time.date %}
<time datetime="{{ self.start_time|date:"c" }}">{{ self.start_time|date:"M d g:i a" }}</time>
<time datetime="{{ self.end_time|date:"c" }}">{{ self.end_time|date:"g:i a" }}</time>
<time datetime="{{ self.start_time|date:'c' }}">{{ self.start_time|date:"M d g:i a" }}</time>
<time datetime="{{ self.end_time|date:'c' }}">{{ self.end_time|date:"g:i a" }}</time>
{% else %}
<time datetime="{{ self.start_time|date:"c" }}">{{ self.start_time|date:"M d g:i a" }}</time>
<time datetime="{{ self.end_time|date:"c" }}">{{ self.end_time|date:"M d g:i a" }}</time>
<time datetime="{{ self.start_time|date:'c' }}">{{ self.start_time|date:"M d g:i a" }}</time>
<time datetime="{{ self.end_time|date:'c' }}">{{ self.end_time|date:"M d g:i a" }}</time>
{% endif %}
</p>
<p class="event-hero__add-to-calendar">
<a href="{{ self.get_ical_url }}">Add to calendar</a>
</p>

{# Much of this schema is ported over from the old event template #}
{% if self.location %}
Expand Down

0 comments on commit e0d1f41

Please sign in to comment.