Mercurial > public > sg101
diff contests/views.py @ 1085:16e190fa6ef8
Port contests app to V3 design.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 02 May 2016 20:03:18 -0500 |
parents | 89b240fe9297 |
children |
line wrap: on
line diff
--- a/contests/views.py Wed Apr 27 20:04:05 2016 -0500 +++ b/contests/views.py Mon May 02 20:03:18 2016 -0500 @@ -8,10 +8,31 @@ HttpResponseBadRequest) from django.shortcuts import get_object_or_404 from django.views.decorators.http import require_POST +from django.views.generic import DetailView, ListView from contests.models import Contest +class ContestListView(ListView): + context_object_name = 'contests' + queryset=Contest.public_objects.all() + + def get_context_data(self, **kwargs): + context = super(ContestListView, self).get_context_data(**kwargs) + context['V3_DESIGN'] = True + return context + + +class ContestDetailView(DetailView): + context_object_name = 'contest' + queryset=Contest.public_objects.all().prefetch_related('winners') + + def get_context_data(self, **kwargs): + context = super(ContestDetailView, self).get_context_data(**kwargs) + context['V3_DESIGN'] = True + return context + + @require_POST def enter(request): """