2016-07-13 20:37:20 +00:00
|
|
|
from collections import OrderedDict
|
|
|
|
|
2016-08-04 21:03:39 +00:00
|
|
|
import datetime
|
2016-08-07 13:49:30 +00:00
|
|
|
from django.views.generic import ListView, TemplateView, DetailView
|
2016-12-25 14:52:55 +00:00
|
|
|
from camp.mixins import CampViewMixin
|
2016-07-13 20:37:20 +00:00
|
|
|
|
|
|
|
from . import models
|
|
|
|
|
2016-08-08 17:45:32 +00:00
|
|
|
|
2016-12-25 14:52:55 +00:00
|
|
|
class SpeakerDetailView(CampViewMixin, DetailView):
|
2016-08-08 17:45:32 +00:00
|
|
|
model = models.Speaker
|
|
|
|
template_name = 'speaker_detail.html'
|
|
|
|
|
2016-12-25 14:52:55 +00:00
|
|
|
|
|
|
|
class SpeakerListView(CampViewMixin, ListView):
|
2016-08-08 17:36:13 +00:00
|
|
|
model = models.Speaker
|
|
|
|
template_name = 'speaker_list.html'
|
|
|
|
|
2016-12-25 14:52:55 +00:00
|
|
|
|
|
|
|
class EventListView(CampViewMixin, ListView):
|
2016-08-08 17:36:13 +00:00
|
|
|
model = models.Event
|
|
|
|
template_name = 'event_list.html'
|
2016-07-13 20:37:20 +00:00
|
|
|
|
2016-12-25 14:52:55 +00:00
|
|
|
|
|
|
|
class ProgramOverviewView(CampViewMixin, ListView):
|
2016-07-13 20:37:20 +00:00
|
|
|
model = models.Event
|
2016-08-04 21:03:39 +00:00
|
|
|
template_name = 'program_overview.html'
|
2016-07-13 20:37:20 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super(
|
2016-08-04 21:03:39 +00:00
|
|
|
ProgramOverviewView, self
|
2016-07-13 20:37:20 +00:00
|
|
|
).get_context_data(**kwargs)
|
|
|
|
|
|
|
|
days = Day.objects.all()
|
2016-08-04 21:03:39 +00:00
|
|
|
context['days'] = days
|
|
|
|
|
|
|
|
filter = {}
|
|
|
|
if 'type' in self.request.GET:
|
|
|
|
event_type = self.request.GET['type']
|
|
|
|
filter["event_type__slug"] = event_type
|
|
|
|
|
|
|
|
context['day_events'] = OrderedDict([
|
|
|
|
(
|
|
|
|
day,
|
|
|
|
self.get_queryset().filter(
|
|
|
|
days__in=[day],
|
|
|
|
**filter
|
|
|
|
).order_by(
|
|
|
|
'start'
|
|
|
|
)
|
|
|
|
)
|
2016-07-13 20:37:20 +00:00
|
|
|
for day in days
|
|
|
|
])
|
|
|
|
|
2016-08-04 21:03:39 +00:00
|
|
|
context['event_types'] = models.EventType.objects.all()
|
|
|
|
|
|
|
|
return context
|
|
|
|
|
|
|
|
|
2016-12-25 14:52:55 +00:00
|
|
|
class ProgramDayView(CampViewMixin, TemplateView):
|
2016-08-04 21:03:39 +00:00
|
|
|
template_name = 'program_day.html'
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super(ProgramDayView, self).get_context_data(**kwargs)
|
|
|
|
year = int(kwargs['year'])
|
|
|
|
month = int(kwargs['month'])
|
|
|
|
day = int(kwargs['day'])
|
|
|
|
date = datetime.date(year=year, month=month, day=day)
|
|
|
|
day = Day.objects.filter(date=date)
|
2016-08-08 19:16:43 +00:00
|
|
|
context['date'] = date
|
2016-08-09 16:38:32 +00:00
|
|
|
context['events'] = models.Event.objects.filter(days=day).order_by('event_type', 'start')
|
2016-08-04 21:03:39 +00:00
|
|
|
context['event_types'] = models.EventType.objects.all()
|
|
|
|
context['days'] = Day.objects.filter(date__year=year)
|
2016-07-13 20:37:20 +00:00
|
|
|
return context
|
2016-07-13 17:13:47 +00:00
|
|
|
|
2016-08-07 13:49:30 +00:00
|
|
|
|
2016-12-25 14:52:55 +00:00
|
|
|
class EventDetailView(CampViewMixin, DetailView):
|
2016-08-07 13:49:30 +00:00
|
|
|
model = models.Event
|
|
|
|
template_name = 'program_event_detail.html'
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super(EventDetailView, self).get_context_data(**kwargs)
|
|
|
|
# TODO: date__year is hardcoded here - need fix for 2017 :P
|
|
|
|
context['days'] = Day.objects.filter(date__year=2016)
|
|
|
|
return context
|
2016-12-25 14:52:55 +00:00
|
|
|
|
|
|
|
|