2017-02-18 01:10:30 +01:00
|
|
|
from django.views.generic import TemplateView
|
2018-08-26 21:18:51 +02:00
|
|
|
from django.views.generic import DetailView
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
|
|
|
|
from .models import Event, Activity
|
|
|
|
from equipment.models import EquipmentAttribution
|
2016-09-30 20:10:35 +02:00
|
|
|
|
2017-02-18 01:10:30 +01:00
|
|
|
|
|
|
|
class Index(TemplateView):
|
|
|
|
template_name = "event/index.html"
|
2018-08-26 21:18:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
class EventView(LoginRequiredMixin, DetailView):
|
|
|
|
model = Event
|
|
|
|
template_name = 'event/event.html'
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
event = self.object
|
|
|
|
context['activities'] = (Activity.objects.filter(event=event)
|
|
|
|
.order_by('beginning').prefetch_related(
|
|
|
|
'tags', 'places', 'staff', 'parent'))
|
|
|
|
return context
|
|
|
|
|
|
|
|
|
|
|
|
class ActivityView(LoginRequiredMixin, DetailView):
|
|
|
|
model = Activity
|
|
|
|
template_name = 'event/activity.html'
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
activity = self.object
|
|
|
|
context['attributions'] = (EquipmentAttribution.objects
|
|
|
|
.filter(activity=activity)
|
|
|
|
.prefetch_related('equipment'))
|
|
|
|
return context
|