Commit 96e6d33f authored by Luuk Scholten's avatar Luuk Scholten Committed by Sébastiaan Versteeg

Implement duolingual iCal feed

Todo: make old link redirect to the dutch ical feed
parent db37c650
......@@ -9,3 +9,4 @@ django-tinymce==2.3.0
pytz
rcssmin
djangorestframework==3.4.4
django-ical==1.4
from django.urls import reverse
from django.utils.translation import activate
from django_ical.views import ICalFeed
from events.models import Event
from django.utils.translation import ugettext as _
class EventFeed(ICalFeed):
def __init__(self, lang='en'):
super().__init__()
self.lang = lang
def product_id(self):
return '-//thalia.nu//EventCalendar//' + self.lang.upper()
def file_name(self):
return "thalia_{}.ics".format(self.lang)
def title(self):
activate(self.lang)
return _('Study Association Thalia event calendar')
def items(self):
return Event.objects.filter(published=True).order_by('-start')
def item_title(self, item):
return item.title
def item_description(self, item):
return item.description
def item_start_datetime(self, item):
return item.start
def item_end_datetime(self, item):
return item.end
def item_link(self, item):
return reverse('events:event', kwargs={'event_id': item.id})
def item_location(self, item):
return "{} - {}".format(item.location, item.map_location)
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-16 08:49+0200\n"
"PO-Revision-Date: 2016-09-16 12:52+0200\n"
"POT-Creation-Date: 2016-09-20 21:26+0200\n"
"PO-Revision-Date: 2016-09-20 21:27+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: nl\n"
......@@ -38,6 +38,10 @@ msgstr "Publiceer geselecteerde evenementen"
msgid "Unpublish selected events"
msgstr "Publicatie van geselecteerde evenementen ongedaan maken"
#: feeds.py:23
msgid "Study Association Thalia event calendar"
msgstr "Studievereniginig Thalia evenementenkalender"
#: models.py:13
msgid "No registration required"
msgstr "Geen registratie vereist"
......
......@@ -13,7 +13,12 @@
{% trans "Calendar" %}
<span class="title-meta clearfix">
<span>
<a href="{% url '#' %}" id="collectionButton" target="_blank" class="calendar">
<a href="{% url 'events:ical-'|add:LANGUAGE_CODE %}"
id="collectionButton"
target="_blank"
class="calendar"
title="iCal feed"
>
<i class="fa fa-calendar"></i>
</a>
</span>
......
......@@ -4,6 +4,7 @@ Events URL Configuration
from django.conf.urls import url
from events.feeds import EventFeed
from . import views
urlpatterns = [
......@@ -11,4 +12,6 @@ urlpatterns = [
url(r'admin/(?P<event_id>\d+)/export/$', views.export, name='export'),
url(r'^(?P<event_id>\d+)$', views.event, name='event'),
url(r'^$', views.index, name='index'),
url(r'^ical/nl.ics', EventFeed(lang='nl'), name='ical-nl'),
url(r'^ical/en.ics', EventFeed(), name='ical-en'),
]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment