diff --git a/requirements/base.txt b/requirements/base.txt index d2fe5479..ad552399 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -10,3 +10,4 @@ easy-thumbnails==2.3 html5lib==0.9999999 markdown==2.6.5 pytz==2015.7 +django-ical==1.4 diff --git a/symposion/schedule/urls.py b/symposion/schedule/urls.py index 28b05f1f..7dc6befb 100644 --- a/symposion/schedule/urls.py +++ b/symposion/schedule/urls.py @@ -13,6 +13,7 @@ from .views import ( session_staff_email, session_list, session_detail, + EventFeed ) urlpatterns = [ @@ -27,6 +28,7 @@ urlpatterns = [ url(r"^([\w\-]+)/presentations.csv$", schedule_list_csv, name="schedule_list_csv"), url(r"^([\w\-]+)/edit/slot/(\d+)/", schedule_slot_edit, name="schedule_slot_edit"), url(r"^conference.json", schedule_json, name="schedule_json"), + url(r"^conference.ics", EventFeed(), name="ical_feed"), url(r"^sessions/staff.txt$", session_staff_email, name="schedule_session_staff_email"), url(r"^sessions/$", session_list, name="schedule_session_list"), url(r"^session/(\d+)/$", session_detail, name="schedule_session_detail"), diff --git a/symposion/schedule/views.py b/symposion/schedule/views.py index 2cc7fa8a..a3881145 100644 --- a/symposion/schedule/views.py +++ b/symposion/schedule/views.py @@ -10,6 +10,8 @@ from django.contrib.auth.models import User from django.contrib import messages from django.contrib.sites.models import Site +from django_ical.views import ICalFeed + from account.decorators import login_required from symposion.schedule.forms import SlotEditForm, ScheduleSectionForm @@ -256,6 +258,47 @@ def schedule_json(request): content_type="application/json" ) +class EventFeed(ICalFeed): + + product_id = '-//linux.conf.au/schedule//EN' + timezone = 'Australia/Tasmania' + filename = 'conference.ics' + + def items(self): + return Slot.objects.filter( + day__schedule__published=True, + day__schedule__hidden=False + ).order_by("start") + + def item_title(self, item): + if hasattr(item.content, 'proposal'): + return item.content.title + else: + item.content_override if item.content_override else "Slot" + + def item_description(self, item): + if hasattr(item.content, 'proposal'): + return item.content.abstract + else: + return None + + def item_start_datetime(self, item): + return item.start_datetime + + def item_end_datetime(self, item): + return item.end_datetime + + def item_location(self, item): + return ", ".join(room["name"] for room in item.rooms.values()) + + def item_link(self, item): + if hasattr(item.content, 'proposal'): + return 'http://%s%s' % ( + Site.objects.get_current().domain, + reverse('schedule_presentation_detail', args=[item.content.pk]) + ) + else: + return 'http://%s' % Site.objects.get_current().domain def session_list(request): sessions = Session.objects.all().order_by('pk')