bornhack-website/camps/mixins.py

15 lines
449 B
Python
Raw Normal View History

from camps.models import Camp
from django.shortcuts import get_object_or_404
2016-12-28 23:15:13 +00:00
class CampViewMixin(object):
def dispatch(self, request, *args, **kwargs):
2016-12-28 23:15:13 +00:00
self.camp = get_object_or_404(Camp, slug=self.kwargs['camp_slug'])
return super(CampViewMixin, self).dispatch(request, *args, **kwargs)
def get_queryset(self):
2016-12-28 23:15:13 +00:00
queryset = super(CampViewMixin, self).get_queryset()
return queryset.filter(camp=self.camp)