bornhack-website/camps/mixins.py
2016-12-29 00:15:13 +01:00

15 lines
449 B
Python

from camps.models import Camp
from django.shortcuts import get_object_or_404
class CampViewMixin(object):
def dispatch(self, request, *args, **kwargs):
self.camp = get_object_or_404(Camp, slug=self.kwargs['camp_slug'])
return super(CampViewMixin, self).dispatch(request, *args, **kwargs)
def get_queryset(self):
queryset = super(CampViewMixin, self).get_queryset()
return queryset.filter(camp=self.camp)