comparison 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
comparison
equal deleted inserted replaced
1084:5fa22ed8bfb2 1085:16e190fa6ef8
6 6
7 from django.http import (HttpResponse, HttpResponseForbidden, 7 from django.http import (HttpResponse, HttpResponseForbidden,
8 HttpResponseBadRequest) 8 HttpResponseBadRequest)
9 from django.shortcuts import get_object_or_404 9 from django.shortcuts import get_object_or_404
10 from django.views.decorators.http import require_POST 10 from django.views.decorators.http import require_POST
11 from django.views.generic import DetailView, ListView
11 12
12 from contests.models import Contest 13 from contests.models import Contest
14
15
16 class ContestListView(ListView):
17 context_object_name = 'contests'
18 queryset=Contest.public_objects.all()
19
20 def get_context_data(self, **kwargs):
21 context = super(ContestListView, self).get_context_data(**kwargs)
22 context['V3_DESIGN'] = True
23 return context
24
25
26 class ContestDetailView(DetailView):
27 context_object_name = 'contest'
28 queryset=Contest.public_objects.all().prefetch_related('winners')
29
30 def get_context_data(self, **kwargs):
31 context = super(ContestDetailView, self).get_context_data(**kwargs)
32 context['V3_DESIGN'] = True
33 return context
13 34
14 35
15 @require_POST 36 @require_POST
16 def enter(request): 37 def enter(request):
17 """ 38 """