~lars-luthman-deactivatedaccount/ppvalbok/remove-bookings

« back to all changes in this revision

Viewing changes to ballot_system/views.py

  • Committer: Lars Luthman
  • Date: 2009-04-23 23:40:25 UTC
  • Revision ID: lars.luthman@gmail.com-20090423234025-ogb4h5psy3bbswo7
Implemented booking of early voting stations, updated the style of next.html.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                               'early_stations': earlystations, 
35
35
                               'stations': stations})
36
36
 
 
37
def early_station(request, key):
 
38
    station = get_object_or_404(EarlyVotingStation, pk=key)
 
39
    if request.method == 'POST':
 
40
        form = BookingForm(request.POST)
 
41
        if form.is_valid():
 
42
            if station.evsdata.book(form.cleaned_data['email']):
 
43
                request.session['email'] = form.cleaned_data['email']
 
44
                return HttpResponseRedirect('thanks/')
 
45
    else:
 
46
        form = BookingForm()
 
47
    return direct_to_template(request, 'view_early_station.html',
 
48
                              {'station': station,
 
49
                               'form': form})
 
50
 
37
51
def station(request, key):
38
52
    station = get_object_or_404(VotingStation, pk=key)
39
53
    return direct_to_template(request, 'view_station.html',
70
84
 
71
85
    return direct_to_template(request, 'book_station.html', values)
72
86
 
 
87
def book_early_station_thanks(request, key):
 
88
    station = get_object_or_404(EarlyVotingStation, pk=key)
 
89
    return direct_to_template(request, 'book_thanks.html',
 
90
                              {'email': request.session['email']})
 
91
 
73
92
def book_station_thanks(request, key, watch):
74
93
    station = get_object_or_404(VotingStation, pk=key)
75
94
    return direct_to_template(request, 'book_thanks.html',
88
107
    elif booking.third_watch.count() == 1:
89
108
        values['station'] = booking.third_watch.get().votingstation
90
109
        values['third_watch'] = True
91
 
    else:
92
 
        raise Http404
 
110
    elif booking.evsdata_set.count() == 1:
 
111
        values['early_station'] = booking.evsdata_set.get().earlyvotingstation
93
112
    
94
113
    booking.confirmed = True
95
114
    booking.save()