Adds an ical feed and track name to room
This commit is contained in:
commit
72c3d623b4
7 changed files with 128 additions and 1 deletions
|
@ -10,3 +10,4 @@ easy-thumbnails==2.3
|
|||
html5lib==0.9999999
|
||||
markdown==2.6.5
|
||||
pytz==2015.7
|
||||
django-ical==1.4
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import unicode_literals
|
||||
from django.contrib import admin
|
||||
|
||||
from symposion.schedule.models import Schedule, Day, Room, SlotKind, Slot, SlotRoom, Presentation, Session, SessionRole
|
||||
from symposion.schedule.models import Schedule, Day, Room, SlotKind, Slot, SlotRoom, Presentation, Session, SessionRole, Track
|
||||
|
||||
|
||||
class DayInline(admin.StackedInline):
|
||||
|
@ -55,3 +55,4 @@ admin.site.register(Slot, SlotAdmin)
|
|||
admin.site.register(Session)
|
||||
admin.site.register(SessionRole)
|
||||
admin.site.register(Presentation, PresentationAdmin)
|
||||
admin.site.register(Track)
|
||||
|
|
20
symposion/schedule/migrations/0006_room_track.py
Normal file
20
symposion/schedule/migrations/0006_room_track.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.7 on 2016-12-24 00:10
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('symposion_schedule', '0005_auto_20161210_1736'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='room',
|
||||
name='track',
|
||||
field=models.CharField(blank=True, default=None, max_length=80, null=True, verbose_name='Track'),
|
||||
),
|
||||
]
|
41
symposion/schedule/migrations/0007_auto_20161224_1709.py
Normal file
41
symposion/schedule/migrations/0007_auto_20161224_1709.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.7 on 2016-12-24 06:09
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('symposion_schedule', '0006_room_track'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Track',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=80, verbose_name='Track')),
|
||||
('day', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='symposion_schedule.Day')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Track',
|
||||
'verbose_name_plural': 'Tracks',
|
||||
},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='room',
|
||||
name='track',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='track',
|
||||
name='room',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='symposion_schedule.Room'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='track',
|
||||
unique_together=set([('room', 'day')]),
|
||||
),
|
||||
]
|
|
@ -61,6 +61,21 @@ class Room(models.Model):
|
|||
verbose_name_plural = _("Rooms")
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Track(models.Model):
|
||||
name = models.CharField(max_length=80, verbose_name=_("Track"))
|
||||
room = models.ForeignKey(Room)
|
||||
day = models.ForeignKey(Day)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
unique_together = [('room', 'day')]
|
||||
verbose_name = _("Track")
|
||||
verbose_name_plural = _("Tracks")
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SlotKind(models.Model):
|
||||
"""
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
from __future__ import unicode_literals
|
||||
import json
|
||||
import pytz
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import Http404, HttpResponse
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.template import loader, Context
|
||||
from django.conf import settings
|
||||
|
||||
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
|
||||
|
@ -48,8 +52,10 @@ def schedule_conference(request):
|
|||
"days": days,
|
||||
})
|
||||
|
||||
day_switch = request.GET.get('day', None)
|
||||
ctx = {
|
||||
"sections": sections,
|
||||
"day_switch": day_switch
|
||||
}
|
||||
return render(request, "symposion/schedule/schedule_conference.html", ctx)
|
||||
|
||||
|
@ -256,6 +262,47 @@ def schedule_json(request):
|
|||
content_type="application/json"
|
||||
)
|
||||
|
||||
class EventFeed(ICalFeed):
|
||||
|
||||
product_id = '-//linux.conf.au/schedule//EN'
|
||||
timezone = settings.TIME_ZONE
|
||||
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 pytz.timezone(settings.TIME_ZONE).localize(item.start_datetime)
|
||||
|
||||
def item_end_datetime(self, item):
|
||||
return pytz.timezone(settings.TIME_ZONE).localize(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')
|
||||
|
|
Loading…
Reference in a new issue