author | primal primal007@gmail.com |
Tue, 06 Dec 2011 15:21:43 +0530 | |
branch | 2011 |
changeset 514 | 23b06e07364d |
parent 365 | 9fb175da83a5 |
permissions | -rw-r--r-- |
342
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
1 |
import csv |
310
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
2 |
import datetime |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
3 |
import time |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
4 |
|
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
5 |
from django.contrib.auth import authenticate |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
6 |
from django.contrib.auth import login |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
from django.contrib.auth.decorators import login_required |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
from django.contrib.auth.forms import AuthenticationForm |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
from django.contrib.auth.models import User |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
from django.core.exceptions import ObjectDoesNotExist |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
11 |
from django.core.urlresolvers import reverse |
342
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
12 |
from django.http import HttpResponse |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
13 |
from django.http import HttpResponseRedirect |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
14 |
from django.shortcuts import render_to_response |
291
182b03a1e6fe
Add a way to send mail as confirmation for users for manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
276
diff
changeset
|
15 |
from django.template import loader |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
16 |
from django.template import RequestContext |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
|
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
18 |
from project.scipycon.base.models import Event |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
19 |
from project.scipycon.registration.forms import RegistrationEditForm |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
20 |
from project.scipycon.registration.forms import RegistrationSubmitForm |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
21 |
from project.scipycon.registration.forms import AccommodationForm |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
22 |
from project.scipycon.registration.forms import PaymentForm |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
23 |
from project.scipycon.registration.forms import WifiForm |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
24 |
from project.scipycon.registration.models import Accommodation |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
25 |
from project.scipycon.registration.models import Payment |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
26 |
from project.scipycon.registration.models import Registration |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
27 |
from project.scipycon.registration.models import Wifi |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
28 |
from project.scipycon.registration.utils import send_confirmation |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
29 |
from project.scipycon.user.forms import RegistrantForm |
96
178b89a3ca4f
Removed unwanted files and made more changes to make SciPyCon a clean app.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
94
diff
changeset
|
30 |
from project.scipycon.user.models import UserProfile |
178b89a3ca4f
Removed unwanted files and made more changes to make SciPyCon a clean app.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
94
diff
changeset
|
31 |
from project.scipycon.user.utils import scipycon_createregistrant |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
32 |
from project.scipycon.utils import set_message_cookie |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
33 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
34 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
35 |
REG_TOTAL = 1000 |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
36 |
|
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
37 |
|
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
38 |
@login_required |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
39 |
def registrations(request, scope, |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
40 |
template_name='registration/registrations.html'): |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
41 |
"""Simple page to count registrations""" |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
42 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
43 |
registrations = Registration.objects.all().count() |
142
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
44 |
|
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
45 |
user = request.user |
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
46 |
if user.is_authenticated(): |
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
47 |
registration = Registration.objects.get(registrant=user) |
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
48 |
else: |
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
49 |
registration = None |
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
50 |
|
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
51 |
event = Event.objects.get(scope=scope) |
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
52 |
|
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
53 |
return render_to_response(template_name, RequestContext(request, { |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
54 |
'params': {'scope': scope}, |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
55 |
'over_reg' : registrations >= REG_TOTAL and True or False, |
142
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
56 |
'registrations' : registrations, |
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
57 |
'registration': registration, |
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
58 |
'event': event})) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
59 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
60 |
@login_required |
111
0e2c94c6a9e8
Adjusted views to send the scope in params.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
106
diff
changeset
|
61 |
def edit_registration(request, scope, id, |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
62 |
template_name='registration/edit-registration.html'): |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
63 |
"""Allows users that submitted a registration to edit it. |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
64 |
""" |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
65 |
|
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
66 |
scope_entity = Event.objects.get(scope=scope) |
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
67 |
|
233
394576ff8a2f
Fix major bug: Change hard coded registration form redirect to based on User and do int conversions for ids.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
231
diff
changeset
|
68 |
reg = Registration.objects.get(pk=int(id)) |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
69 |
wifi = Wifi.objects.get(user=reg.registrant) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
70 |
|
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
71 |
# TODO: This is an ugly hack to add accommodation and payment forms |
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
72 |
# details at later stage for SciPy.in 2010. This must be removed for |
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
73 |
# SciPy.in 2011 |
247
2907855f18c4
Rename created variable name to acco_created for acco object creation in edit registration view function.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
202
diff
changeset
|
74 |
acco, acco_created = Accommodation.objects.get_or_create( |
2907855f18c4
Rename created variable name to acco_created for acco object creation in edit registration view function.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
202
diff
changeset
|
75 |
user=reg.registrant, scope=scope_entity) |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
76 |
payment, payment_created = Payment.objects.get_or_create( |
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
77 |
user=reg.registrant, scope=scope_entity) |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
78 |
|
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
79 |
if reg.registrant != request.user: |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
80 |
redirect_to = reverse('scipycon_account', kwargs={'scope': scope}) |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
81 |
|
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
82 |
return set_message_cookie( |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
83 |
redirect_to, |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
84 |
msg = u'Redirected because the registration you selected' \ |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
85 |
+ ' is not your own.') |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
86 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
87 |
if request.method == 'POST': |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
88 |
registration_form = RegistrationEditForm(data=request.POST) |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
89 |
wifi_form = WifiForm(data=request.POST) |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
90 |
acco_form = AccommodationForm(data=request.POST) |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
91 |
payment_form = PaymentForm(data=request.POST) |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
92 |
|
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
93 |
if (registration_form.is_valid() and wifi_form.is_valid() and |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
94 |
acco_form.is_valid() and payment_form.is_valid()): |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
95 |
reg.organisation = registration_form.data.get('organisation') |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
96 |
reg.occupation = registration_form.data.get('occupation') |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
97 |
reg.city = registration_form.data.get('city') |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
98 |
reg.phone_num = registration_form.data.get('phone_num') |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
99 |
reg.postcode = registration_form.data.get('postcode') |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
100 |
#reg.tshirt = registration_form.data.get('tshirt') |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
101 |
reg.allow_contact = registration_form.data.get( |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
102 |
'allow_contact') and True or False |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
103 |
reg.conference = registration_form.data.get( |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
104 |
'conference') and True or False |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
105 |
reg.tutorial = registration_form.data.get( |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
106 |
'tutorial') and True or False |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
107 |
reg.sprint = registration_form.data.get( |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
108 |
'sprint') and True or False |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
109 |
reg.save() |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
110 |
|
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
111 |
wifi = wifi_form.save(reg.registrant, reg.scope) |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
112 |
acco = acco_form.save(reg.registrant, reg.scope) |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
113 |
payment = payment_form.save(reg.registrant, reg.scope) |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
114 |
|
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
115 |
# Saved.. redirect |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
116 |
redirect_to = reverse('scipycon_account', kwargs={'scope': scope}) |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
117 |
|
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
118 |
return set_message_cookie(redirect_to, |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
119 |
msg = u'Your changes have been saved.') |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
120 |
else: |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
121 |
registration_form = RegistrationEditForm(initial={ |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
122 |
'id' : id, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
123 |
'organisation' : reg.organisation, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
124 |
'occupation' : reg.occupation, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
125 |
'city' : reg.city, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
126 |
'phone_num': reg.phone_num, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
127 |
#'tshirt' : reg.tshirt, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
128 |
'conference': reg.conference, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
129 |
'tutorial': reg.tutorial, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
130 |
'postcode' : reg.postcode, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
131 |
'sprint' : reg.sprint, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
132 |
'allow_contact' : reg.allow_contact, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
133 |
}) |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
134 |
wifi_form = WifiForm(initial={ |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
135 |
'user': wifi.user, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
136 |
'scope': wifi.scope, |
273
5129e1427557
Add registration_id field to initial form in the field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
233
diff
changeset
|
137 |
'wifi': wifi.wifi, |
5129e1427557
Add registration_id field to initial form in the field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
233
diff
changeset
|
138 |
'registration_id': wifi.registration_id |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
139 |
}) |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
140 |
acco_form = AccommodationForm(initial={ |
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
141 |
'user': acco.user, |
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
142 |
'scope': acco.scope, |
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
143 |
'sex': acco.sex, |
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
144 |
'accommodation_required': acco.accommodation_required, |
318
6963bc54d5c2
Fix preceding accommodation which were stolen away by magic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
310
diff
changeset
|
145 |
'accommodation_on_1st': acco.accommodation_on_1st, |
6963bc54d5c2
Fix preceding accommodation which were stolen away by magic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
310
diff
changeset
|
146 |
'accommodation_on_2nd': acco.accommodation_on_2nd, |
6963bc54d5c2
Fix preceding accommodation which were stolen away by magic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
310
diff
changeset
|
147 |
'accommodation_on_3rd': acco.accommodation_on_3rd, |
6963bc54d5c2
Fix preceding accommodation which were stolen away by magic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
310
diff
changeset
|
148 |
'accommodation_on_4th': acco.accommodation_on_4th, |
6963bc54d5c2
Fix preceding accommodation which were stolen away by magic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
310
diff
changeset
|
149 |
'accommodation_on_5th': acco.accommodation_on_5th, |
6963bc54d5c2
Fix preceding accommodation which were stolen away by magic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
310
diff
changeset
|
150 |
'accommodation_on_6th': acco.accommodation_on_6th, |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
151 |
}) |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
152 |
payment_form = PaymentForm(initial={ |
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
153 |
'user': payment.user, |
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
154 |
'scope': payment.scope, |
263
02593358eddc
Made adjustments in the view to make paid field a dummy form field and not a model field. Also added confirmed field as model field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
257
diff
changeset
|
155 |
'paid': payment.type or payment.details, |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
156 |
'type': payment.type, |
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
157 |
'details': payment.details, |
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
158 |
}) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
159 |
|
111
0e2c94c6a9e8
Adjusted views to send the scope in params.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
106
diff
changeset
|
160 |
return render_to_response( |
0e2c94c6a9e8
Adjusted views to send the scope in params.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
106
diff
changeset
|
161 |
template_name, RequestContext(request, { |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
162 |
'params': {'scope': scope}, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
163 |
'registration': {'id': id}, |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
164 |
'registration_form': registration_form, |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
165 |
'wifi_form': wifi_form, |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
166 |
'acco_form': acco_form, |
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
167 |
'payment_form': payment_form})) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
168 |
|
106
3a31881564ba
Add a scope pattern to the URLs.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
96
diff
changeset
|
169 |
def submit_registration(request, scope, |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
170 |
template_name='registration/submit-registration.html'): |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
171 |
"""Allows user to edit registration |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
172 |
""" |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
173 |
|
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
174 |
user = request.user |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
175 |
reg_count = Registration.objects.all().count() |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
176 |
|
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
177 |
scope_entity = Event.objects.get(scope=scope) |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
178 |
|
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
179 |
if user.is_authenticated(): |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
180 |
try: |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
181 |
profile = user.get_profile() |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
182 |
except: |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
183 |
profile, new = UserProfile.objects.get_or_create( |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
184 |
user=user, scope=scope_entity) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
185 |
if new: |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
186 |
profile.save() |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
187 |
try: |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
188 |
registration = Registration.objects.get(registrant=user) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
189 |
if registration: |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
190 |
redirect_to = reverse('scipycon_account', |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
191 |
kwargs={'scope': scope}) |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
192 |
return set_message_cookie( |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
193 |
redirect_to, msg = u'You have already been registered.') |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
194 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
195 |
except ObjectDoesNotExist: |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
196 |
pass |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
197 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
198 |
message = None |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
199 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
200 |
if request.method == 'POST': |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
201 |
registration_form = RegistrationSubmitForm(data=request.POST) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
202 |
registrant_form = RegistrantForm(data=request.POST) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
203 |
wifi_form = WifiForm(data=request.POST) |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
204 |
acco_form = AccommodationForm(data=request.POST) |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
205 |
payment_form = PaymentForm(data=request.POST) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
206 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
207 |
if request.POST.get('action', None) == 'login': |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
208 |
login_form = AuthenticationForm(data=request.POST) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
209 |
if login_form.is_valid(): |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
210 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
211 |
login(request, login_form.get_user()) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
212 |
|
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
213 |
redirect_to = reverse('scipycon_submit_registration', |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
214 |
kwargs={'scope': scope}) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
215 |
return set_message_cookie(redirect_to, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
216 |
msg = u'You have been logged in please continue' + \ |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
217 |
'with registration.') |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
218 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
219 |
newuser = None |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
220 |
passwd = None |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
221 |
if not user.is_authenticated(): |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
222 |
if registrant_form.is_valid(): |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
223 |
newuser = scipycon_createregistrant( |
142
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
224 |
request, registrant_form.data, scope) |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
225 |
|
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
226 |
# Log in user |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
227 |
passwd = User.objects.make_random_password() |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
228 |
newuser.set_password(passwd) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
229 |
newuser.save() |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
230 |
|
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
231 |
user = authenticate(username=newuser.username, password=passwd) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
232 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
233 |
login(request, user) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
234 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
235 |
newuser = user |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
236 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
237 |
else: |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
238 |
newuser = user |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
239 |
|
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
240 |
if (registration_form.is_valid() and newuser and wifi_form.is_valid() |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
241 |
and acco_form.is_valid() and payment_form.is_valid()): |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
242 |
allow_contact = registration_form.cleaned_data.get( |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
243 |
'allow_contact') and True or False |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
244 |
conference = registration_form.cleaned_data.get( |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
245 |
'conference') and True or False |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
246 |
tutorial = registration_form.cleaned_data.get('tutorial') and \ |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
247 |
True or False |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
248 |
sprint = registration_form.cleaned_data.get('sprint') and \ |
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
249 |
True or False |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
250 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
251 |
registrant = User.objects.get(pk=newuser.id) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
252 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
253 |
reg = Registration( |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
254 |
scope=scope_entity, |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
255 |
registrant = registrant, |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
256 |
organisation = registration_form.cleaned_data.get( |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
257 |
'organisation'), |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
258 |
occupation = registration_form.cleaned_data.get('occupation'), |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
259 |
city = registration_form.cleaned_data.get('city'), |
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
260 |
#tshirt = registration_form.data.get('tshirt'), |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
261 |
postcode = registration_form.cleaned_data.get('postcode'), |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
262 |
phone_num = registration_form.cleaned_data.get('phone_num'), |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
263 |
allow_contact = allow_contact, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
264 |
conference = conference, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
265 |
tutorial = tutorial, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
266 |
sprint = sprint) |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
267 |
reg.save() |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
268 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
269 |
# get id and use as slug and invoice number |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
270 |
id = reg.id |
142
70fcb57d8d15
Added event and registrants to Registration summary page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
137
diff
changeset
|
271 |
slug = 'SCIPYIN2010%04d' % id |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
272 |
reg.slug = slug |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
273 |
reg.save() |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
274 |
|
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
275 |
wifi = wifi_form.save(registrant, scope_entity) |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
276 |
acco = acco_form.save(registrant, scope_entity) |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
277 |
payment = payment_form.save(registrant, scope_entity) |
137
ec6e58c639bf
Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
126
diff
changeset
|
278 |
|
231 | 279 |
send_confirmation(registrant, scope_entity, password=passwd) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
280 |
|
126
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
281 |
redirect_to = reverse('scipycon_registrations', |
f185cb8316cf
Added scope to all URLs, all reverse functions and all view methods and removed unnecessary functions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
111
diff
changeset
|
282 |
kwargs={'scope': scope}) |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
283 |
return set_message_cookie(redirect_to, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
284 |
msg = u'Thank you, your registration has been submitted '\ |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
285 |
'and an email has been sent with payment details.') |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
286 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
287 |
else: |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
288 |
registration_form = RegistrationSubmitForm() |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
289 |
registrant_form = RegistrantForm() |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
290 |
wifi_form = WifiForm() |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
291 |
acco_form = AccommodationForm() |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
292 |
payment_form = PaymentForm() |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
293 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
294 |
login_form = AuthenticationForm() |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
295 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
296 |
|
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
297 |
return render_to_response(template_name, RequestContext(request, { |
111
0e2c94c6a9e8
Adjusted views to send the scope in params.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
106
diff
changeset
|
298 |
'params': {'scope': scope}, |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
299 |
'registration_form': registration_form, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
300 |
'registrant_form' : registrant_form, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
301 |
'over_reg' : reg_count >= REG_TOTAL and True or False, |
202
b4391b3d5fcc
Edit views to make room for accommodation forms.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
194
diff
changeset
|
302 |
'acco_form': acco_form, |
251
b99607287a52
Add payment forms and object details in edit and submit registration views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
247
diff
changeset
|
303 |
'payment_form': payment_form, |
94
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
304 |
'wifi_form' : wifi_form, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
305 |
'message' : message, |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
306 |
'login_form' : login_form |
87e77aa18610
Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
307 |
})) |
193
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
308 |
|
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
309 |
|
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
310 |
@login_required |
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
311 |
def regstats(request, scope, |
194
808abc104b55
View to calculate the number of registrants per event.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
193
diff
changeset
|
312 |
template_name='registration/regstats.html'): |
193
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
313 |
"""View that gives the statistics of registrants. |
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
314 |
""" |
194
808abc104b55
View to calculate the number of registrants per event.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
193
diff
changeset
|
315 |
|
193
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
316 |
if not request.user.is_staff: |
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
317 |
redirect_to = reverse('scipycon_login', kwargs={'scope': scope}) |
255
b20d55891709
Add cookie and return message for regstats view function.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
251
diff
changeset
|
318 |
return set_message_cookie( |
b20d55891709
Add cookie and return message for regstats view function.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
251
diff
changeset
|
319 |
redirect_to, msg = u'You must be a staff on this website to ' |
b20d55891709
Add cookie and return message for regstats view function.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
251
diff
changeset
|
320 |
'access this page.') |
193
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
321 |
|
342
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
322 |
reg_q = Registration.objects.all() |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
323 |
conf_num = reg_q.filter(conference=True).count() |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
324 |
tut_num = reg_q.filter(tutorial=True).count() |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
325 |
sprint_num = reg_q.filter(sprint=True).count() |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
326 |
|
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
327 |
acco_q = Accommodation.objects.all() |
348
88cb9f42880c
Number of male and female participants requesting accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
347
diff
changeset
|
328 |
male = acco_q.filter(sex='Male').count() |
88cb9f42880c
Number of male and female participants requesting accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
347
diff
changeset
|
329 |
female = acco_q.filter(sex='Female').count() |
350
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
330 |
|
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
331 |
# Day 1 details |
352
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
332 |
day1 = acco_q.filter(accommodation_on_1st=True) |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
333 |
acco_1 = { |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
334 |
'total': day1.count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
335 |
'male': day1.filter(sex='Male').count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
336 |
'female': day1.filter(sex='Female').count() |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
337 |
} |
350
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
338 |
|
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
339 |
# Day 2 details |
352
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
340 |
day2 = acco_q.filter(accommodation_on_2nd=True) |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
341 |
acco_2 = { |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
342 |
'total': day2.count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
343 |
'male': day2.filter(sex='Male').count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
344 |
'female': day2.filter(sex='Female').count() |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
345 |
} |
350
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
346 |
|
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
347 |
# Day 3 details |
352
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
348 |
day3 = acco_q.filter(accommodation_on_3rd=True) |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
349 |
acco_3 = { |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
350 |
'total': day3.count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
351 |
'male': day3.filter(sex='Male').count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
352 |
'female': day3.filter(sex='Female').count() |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
353 |
} |
350
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
354 |
|
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
355 |
# Day 4 details |
352
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
356 |
day4 = acco_q.filter(accommodation_on_4th=True) |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
357 |
acco_4 = { |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
358 |
'total': day4.count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
359 |
'male': day4.filter(sex='Male').count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
360 |
'female': day4.filter(sex='Female').count() |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
361 |
} |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
362 |
|
350
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
363 |
|
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
364 |
# Day 5 details |
352
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
365 |
day5 = acco_q.filter(accommodation_on_5th=True) |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
366 |
acco_5 = { |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
367 |
'total': day5.count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
368 |
'male': day5.filter(sex='Male').count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
369 |
'female': day5.filter(sex='Female').count() |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
370 |
} |
350
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
371 |
|
baf939071b60
Male and Female participants stats on website.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
349
diff
changeset
|
372 |
# Day 6 details |
352
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
373 |
day6 = acco_q.filter(accommodation_on_6th=True) |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
374 |
acco_6 = { |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
375 |
'total': day6.count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
376 |
'male': day6.filter(sex='Male').count(), |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
377 |
'female': day6.filter(sex='Female').count() |
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
378 |
} |
193
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
379 |
|
ed5828a90109
Copy the download csv code that was earlier written but scraped.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
186
diff
changeset
|
380 |
return render_to_response(template_name, RequestContext(request, |
194
808abc104b55
View to calculate the number of registrants per event.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
193
diff
changeset
|
381 |
{'params': {'scope': scope}, |
808abc104b55
View to calculate the number of registrants per event.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
193
diff
changeset
|
382 |
'conf_num': conf_num, |
808abc104b55
View to calculate the number of registrants per event.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
193
diff
changeset
|
383 |
'tut_num': tut_num, |
808abc104b55
View to calculate the number of registrants per event.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
193
diff
changeset
|
384 |
'sprint_num': sprint_num, |
348
88cb9f42880c
Number of male and female participants requesting accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
347
diff
changeset
|
385 |
'male': male, |
88cb9f42880c
Number of male and female participants requesting accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
347
diff
changeset
|
386 |
'female':female, |
352
781d7bc60cc9
Update male and female status and html page rendering for accommodation.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
350
diff
changeset
|
387 |
'acco_days': [acco_1, acco_2, acco_3, acco_4, acco_5, acco_6], |
236 | 388 |
})) |
257
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
389 |
|
342
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
390 |
@login_required |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
391 |
def regstats_download(request, scope): |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
392 |
"""Sends a downloadable PDF for registration statistics |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
393 |
""" |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
394 |
|
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
395 |
if not request.user.is_staff: |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
396 |
redirect_to = reverse('scipycon_login') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
397 |
return HttpResponseRedirect(redirect_to) |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
398 |
|
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
399 |
filename = 'regstats%s.csv' % datetime.datetime.strftime( |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
400 |
datetime.datetime.now(), '%Y%m%d%H%M%S') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
401 |
|
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
402 |
response = HttpResponse(mimetype='text/csv') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
403 |
response['Content-Disposition'] = 'attachment; filename=%s' % ( |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
404 |
filename) |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
405 |
|
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
406 |
output = csv.writer(response) |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
407 |
|
353
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
408 |
output.writerow(['Name', 'Gender', 'City', |
342
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
409 |
'Registration Fees Paid', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
410 |
'Attending Conference', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
411 |
'Attending Tutorial', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
412 |
'Attending Sprint', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
413 |
'Laptop Identification Number', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
414 |
'Accommodation Fees Paid', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
415 |
'Accommodation on 12th night', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
416 |
'Accommodation on 13th night', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
417 |
'Accommodation on 14th night', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
418 |
'Accommodation on 15th night', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
419 |
'Accommodation on 16th night', |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
420 |
'Accommodation on 17th night']) |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
421 |
|
365
9fb175da83a5
Add ordering for names on the CSV list.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
354
diff
changeset
|
422 |
regs = Registration.objects.order_by( |
9fb175da83a5
Add ordering for names on the CSV list.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
354
diff
changeset
|
423 |
'registrant__first_name', 'registrant__last_name') |
342
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
424 |
for reg in regs: |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
425 |
row = [] |
353
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
426 |
|
345
bc50906a9fee
Creating Payment, Accommodation and Wifi objects require scope and user objects.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
343
diff
changeset
|
427 |
payment, create = reg.registrant.payment_set.get_or_create( |
346
c2edf840db70
User and Scope to get_or_create must be keyword arguments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
345
diff
changeset
|
428 |
user=reg.registrant, scope=reg.scope) |
353
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
429 |
acco, created = reg.registrant.accommodation_set.get_or_create( |
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
430 |
user=reg.registrant, scope=reg.scope) |
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
431 |
wifi, create = reg.registrant.wifi_set.get_or_create( |
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
432 |
user=reg.registrant, scope=reg.scope) |
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
433 |
|
354
5fb620cdacf2
Add the string control character for CSV full name field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
353
diff
changeset
|
434 |
row.append('"%s"' % reg.registrant.get_full_name()) |
353
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
435 |
row.append(acco.sex) |
bd083c34aa43
Update gender info on CSV.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
352
diff
changeset
|
436 |
row.append(reg.city) |
343
debfd9506f40
Create payment and wifi objects if they don't exist.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
342
diff
changeset
|
437 |
row.append('Yes' if payment.confirmed else 'No') |
342
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
438 |
row.append('Yes' if reg.conference else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
439 |
row.append('Yes' if reg.tutorial else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
440 |
row.append('Yes' if reg.sprint else 'No') |
343
debfd9506f40
Create payment and wifi objects if they don't exist.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
342
diff
changeset
|
441 |
row.append(wifi.registration_id) |
345
bc50906a9fee
Creating Payment, Accommodation and Wifi objects require scope and user objects.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
343
diff
changeset
|
442 |
row.append('Yes' if payment.acco_confirmed |
342
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
443 |
else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
444 |
row.append('Yes' if acco.accommodation_on_1st else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
445 |
row.append('Yes' if acco.accommodation_on_2nd else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
446 |
row.append('Yes' if acco.accommodation_on_3rd else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
447 |
row.append('Yes' if acco.accommodation_on_4th else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
448 |
row.append('Yes' if acco.accommodation_on_5th else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
449 |
row.append('Yes' if acco.accommodation_on_6th else 'No') |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
450 |
output.writerow(row) |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
451 |
|
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
452 |
#output.writerow() |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
453 |
return response |
21dc37050a37
Make downloadable CSV for stats page.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
318
diff
changeset
|
454 |
|
257
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
455 |
|
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
456 |
@login_required |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
457 |
def manage_payments(request, scope, |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
458 |
template_name='registration/manage_payments.html'): |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
459 |
"""View that gives a form to manage payments. |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
460 |
""" |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
461 |
|
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
462 |
if not request.user.is_superuser: |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
463 |
redirect_to = reverse('scipycon_login', kwargs={'scope': scope}) |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
464 |
return set_message_cookie( |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
465 |
redirect_to, msg = u'You must be an admin on this website to ' |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
466 |
'access this page.') |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
467 |
|
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
468 |
message = None |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
469 |
|
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
470 |
scope_entity = Event.objects.get(scope=scope) |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
471 |
|
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
472 |
if request.method == 'POST': |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
473 |
post_data = request.POST |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
474 |
list_user_ids = [] |
291
182b03a1e6fe
Add a way to send mail as confirmation for users for manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
276
diff
changeset
|
475 |
|
182b03a1e6fe
Add a way to send mail as confirmation for users for manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
276
diff
changeset
|
476 |
mail_subject = 'SciPy.in 2010: Confirmation of fee payment' |
182b03a1e6fe
Add a way to send mail as confirmation for users for manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
276
diff
changeset
|
477 |
mail_template = 'notifications/payment_confirmation2010.html' |
182b03a1e6fe
Add a way to send mail as confirmation for users for manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
276
diff
changeset
|
478 |
|
310
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
479 |
def parse_form(): |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
480 |
"""Helper function that gets the User ID from the |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
481 |
form name |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
482 |
""" |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
483 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
484 |
confirmed_ids = [] |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
485 |
acco_ids = [] |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
486 |
date_ids = {} |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
487 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
488 |
for name_string in post_data: |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
489 |
id_str_list = name_string.split('_') |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
490 |
if (len(id_str_list) == 3 and id_str_list[1] == 'id'): |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
491 |
if id_str_list[0] == 'confirmed': |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
492 |
confirmed_ids.append(int(id_str_list[2])) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
493 |
if id_str_list[0] == 'acco': |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
494 |
acco_ids.append(int(id_str_list[2])) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
495 |
if id_str_list[0] == 'date': |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
496 |
date_str = post_data.get(name_string, None) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
497 |
if date_str: |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
498 |
date_ids[int(id_str_list[2])] = post_data.get( |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
499 |
name_string, '') |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
500 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
501 |
return confirmed_ids, acco_ids, date_ids |
257
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
502 |
|
310
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
503 |
confirmed_ids, acco_ids, date_ids = parse_form() |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
504 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
505 |
confirmed_users = set(User.objects.filter(id__in=confirmed_ids)) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
506 |
acco_users = set(User.objects.filter(id__in=acco_ids)) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
507 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
508 |
# Users for whom both registration and accommodation is confirmed |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
509 |
for user in confirmed_users & acco_users: |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
510 |
payment, created = user.payment_set.get_or_create( |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
511 |
user=user, scope=scope_entity) |
257
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
512 |
|
310
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
513 |
payment.confirmed = True |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
514 |
payment.acco_confirmed = True |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
515 |
payment.save() |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
516 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
517 |
if not payment.confirmed_mail and not payment.acco_confirmed_mail: |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
518 |
mail_message = loader.render_to_string( |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
519 |
mail_template, |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
520 |
dictionary={'name': user.get_full_name(), |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
521 |
'acco': True, |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
522 |
'reg': True}) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
523 |
user.email_user(mail_subject, mail_message, |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
524 |
from_email='admin@scipy.in') |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
525 |
payment.confirmed_mail =True |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
526 |
payment.acco_confirmed_mail = True |
257
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
527 |
payment.save() |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
528 |
|
310
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
529 |
# Users for whom only registration is confirmed |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
530 |
for user in confirmed_users - acco_users: |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
531 |
payment, created = user.payment_set.get_or_create( |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
532 |
user=user, scope=scope_entity) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
533 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
534 |
payment.confirmed = True |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
535 |
payment.save() |
257
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
536 |
|
310
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
537 |
if not payment.confirmed_mail: |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
538 |
mail_message = loader.render_to_string( |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
539 |
mail_template, |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
540 |
dictionary={'name': user.get_full_name(), |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
541 |
'reg': True}) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
542 |
user.email_user(mail_subject, mail_message, |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
543 |
from_email='admin@scipy.in') |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
544 |
payment.confirmed_mail =True |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
545 |
payment.save() |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
546 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
547 |
# Users for whom only accommodation is confirmed |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
548 |
for user in acco_users - confirmed_users: |
257
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
549 |
payment, created = user.payment_set.get_or_create( |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
550 |
user=user, scope=scope_entity) |
310
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
551 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
552 |
payment.acco_confirmed = True |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
553 |
payment.save() |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
554 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
555 |
if not payment.acco_confirmed_mail: |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
556 |
mail_message = loader.render_to_string( |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
557 |
mail_template, |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
558 |
dictionary={'name': user.get_full_name(), |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
559 |
'acco': True}) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
560 |
user.email_user(mail_subject, mail_message, |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
561 |
from_email='admin@scipy.in') |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
562 |
payment.acco_confirmed_mail = True |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
563 |
payment.save() |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
564 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
565 |
# Users for whom fee payment date is updated |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
566 |
for id in date_ids: |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
567 |
user = User.objects.get(id=id) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
568 |
payment, created = user.payment_set.get_or_create( |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
569 |
user=user, scope=scope_entity) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
570 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
571 |
time_format = "%m/%d/%Y" |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
572 |
date = datetime.datetime.fromtimestamp(time.mktime( |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
573 |
time.strptime(date_ids[id], time_format))) |
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
574 |
|
3541adaa5cd3
Provide Javascript support and add all view related changes for form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
291
diff
changeset
|
575 |
payment.date_confirmed = date |
257
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
576 |
payment.save() |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
577 |
|
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
578 |
registrants = Registration.objects.all() |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
579 |
|
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
580 |
return render_to_response(template_name, RequestContext(request, |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
581 |
{'params': {'scope': scope}, |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
582 |
'registrants': registrants, |
e2ff0c70014d
Add a view to manage payments.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
255
diff
changeset
|
583 |
})) |