author | nishanth |
Thu, 15 Jul 2010 14:21:09 +0530 | |
branch | anoop |
changeset 95 | ab554d46fd34 |
parent 93 | 505989755cd8 |
child 97 | bf16c82df506 |
permissions | -rw-r--r-- |
15 | 1 |
from django.shortcuts import render_to_response, redirect |
26
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
2 |
from django.http import HttpResponse |
65
0ca63c964237
now login is required for accessing stats and send_invi pages
nishanth
parents:
57
diff
changeset
|
3 |
from django.contrib.auth.decorators import login_required |
7 | 4 |
|
67 | 5 |
from django.contrib.auth import authenticate, login, logout |
6 |
||
7 | 7 |
from sage_days.sdi.models import Registrant |
90
1a6e1af98624
now selecting users through forms. created a form for that
nishanth
parents:
88
diff
changeset
|
8 |
from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm |
56 | 9 |
from sage_days.sdi.events import send_reg_complete_mail, mail_invi |
72 | 10 |
from sage_days.settings import APACHE_URL_PREFIX as aup |
7 | 11 |
|
12 |
def register(request): |
|
13 |
""" The user register page. |
|
14 |
""" |
|
15 |
||
9 | 16 |
if request.method == "POST": |
14 | 17 |
form = RegisterForm(request.POST) |
18 |
if form.is_valid(): |
|
15 | 19 |
form.save() |
53 | 20 |
|
21 |
data = form.cleaned_data |
|
22 |
first_name = data['first_name'] |
|
23 |
last_name = data['last_name'] |
|
24 |
email = data['email'] |
|
25 |
send_reg_complete_mail(email, first_name, last_name) |
|
26 |
||
26
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
27 |
return redirect("/sage_days/registration/complete") |
14 | 28 |
else: |
29 |
return render_to_response("register.html", {"form":form}) |
|
9 | 30 |
else: |
31 |
form = RegisterForm() |
|
32 |
return render_to_response("register.html", {"form":form}) |
|
22 | 33 |
|
34 |
def reg_complete(request): |
|
35 |
""" Tell the registration is successful. |
|
36 |
""" |
|
37 |
||
38 |
return render_to_response("reg_complete.html") |
|
23 | 39 |
|
65
0ca63c964237
now login is required for accessing stats and send_invi pages
nishanth
parents:
57
diff
changeset
|
40 |
@login_required |
23 | 41 |
def list_stats(request): |
42 |
""" List the statiscs of registered participants. |
|
43 |
""" |
|
44 |
||
24
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
45 |
if request.method == "POST": |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
46 |
form = SearchForm(request.POST) |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
47 |
if form.is_valid(): |
25 | 48 |
data = form.cleaned_data |
79
064ff60025d9
removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents:
77
diff
changeset
|
49 |
|
064ff60025d9
removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents:
77
diff
changeset
|
50 |
#need_workshop = data['need_for_python_workshop'] |
064ff60025d9
removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents:
77
diff
changeset
|
51 |
#acco_required = data['need_accomodation'] |
064ff60025d9
removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents:
77
diff
changeset
|
52 |
#db_query = "Registrant.objects.filter(need_for_python_workshop=%s, acco_required=%s)"%(need_workshop, acco_required) |
064ff60025d9
removed the need_python_workshop and need_acco fields since they are very confusing
nishanth
parents:
77
diff
changeset
|
53 |
db_query = "Registrant.objects" |
25 | 54 |
|
55 |
topics_include, topics_exclude = data['topics_interested'] |
|
56 |
for number in topics_include: |
|
57 |
db_query += '.filter(topics_interested__contains="%s")'%number |
|
58 |
||
59 |
for number in topics_exclude: |
|
60 |
db_query += '.exclude(topics_interested__contains="%s")'%number |
|
61 |
||
62 |
start_python, stop_python = data['knowledge_of_python'] |
|
63 |
if start_python and stop_python: |
|
64 |
db_query += '.filter(knowledge_of_python__gte="%s")'%start_python |
|
65 |
db_query += '.filter(knowledge_of_python__lte="%s")'%stop_python |
|
66 |
elif start_python: |
|
67 |
db_query += '.filter(knowledge_of_python__exact="%s")'%start_python |
|
68 |
||
69 |
start_sage, stop_sage = data['knowledge_of_sage'] |
|
70 |
if start_sage and stop_sage: |
|
71 |
db_query += '.filter(knowledge_of_sage__gte="%s")'%start_sage |
|
72 |
db_query += '.filter(knowledge_of_sage__lte="%s")'%stop_sage |
|
73 |
elif start_sage: |
|
74 |
db_query += '.filter(knowledge_of_sage__exact="%s")'%start_sage |
|
75 |
||
76 |
start_likeliness, stop_likeliness = data['likeliness_of_attending'] |
|
77 |
if start_likeliness and stop_likeliness: |
|
78 |
db_query += '.filter(likeliness_of_attending__gte="%s")'%start_likeliness |
|
79 |
db_query += '.filter(likeliness_of_attending__lte="%s")'%stop_likeliness |
|
80 |
elif start_likeliness: |
|
81 |
db_query += '.filter(likeliness_of_attending__exact="%s")'%start_likeliness |
|
82 |
||
80
c200156c80a9
fixed a bug that arises when a query does not have any parameters to filter
nishanth
parents:
79
diff
changeset
|
83 |
db_query += ".all()" |
c200156c80a9
fixed a bug that arises when a query does not have any parameters to filter
nishanth
parents:
79
diff
changeset
|
84 |
|
25 | 85 |
matches = eval(db_query) |
86 |
return render_to_response("list_stats.html", {"form":form, 'matches':matches}) |
|
24
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
87 |
else: |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
88 |
return render_to_response("list_stats.html", {"form":form}) |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
89 |
else: |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
90 |
form = SearchForm() |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
91 |
return render_to_response("list_stats.html", {"form":form}) |
26
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
92 |
|
65
0ca63c964237
now login is required for accessing stats and send_invi pages
nishanth
parents:
57
diff
changeset
|
93 |
@login_required |
56 | 94 |
def send_invi(request): |
95 |
""" Take a list of csv email addresses and send mails to them. |
|
96 |
""" |
|
97 |
||
98 |
if request.method == "POST": |
|
99 |
form = EmailForm(request.POST) |
|
100 |
if form.is_valid(): |
|
101 |
to_emails = form.cleaned_data['emails'] |
|
102 |
mail_invi(to_emails) |
|
103 |
return render_to_response("send_invi.html", {"emails":to_emails}) |
|
104 |
else: |
|
105 |
return render_to_response("send_invi.html", {"form":form}) |
|
106 |
else: |
|
57 | 107 |
form = EmailForm() |
56 | 108 |
return render_to_response("send_invi.html", {"form":form}) |
109 |
||
86 | 110 |
@login_required |
111 |
def send_workshop_confirm(request): |
|
112 |
""" Show a list of all the ppl who requested for a workshop and |
|
113 |
send a confirmation mail to them if not sent. |
|
114 |
""" |
|
115 |
||
88 | 116 |
matches = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_workshop="1") |
86 | 117 |
if request.method == "POST": |
93
505989755cd8
modified the form and implemented the view to display selected users
nishanth
parents:
92
diff
changeset
|
118 |
form = UserSelectForm(matches, request.POST) |
505989755cd8
modified the form and implemented the view to display selected users
nishanth
parents:
92
diff
changeset
|
119 |
if form.is_valid(): |
505989755cd8
modified the form and implemented the view to display selected users
nishanth
parents:
92
diff
changeset
|
120 |
selected_users = form.cleaned_data['selected_users'] |
505989755cd8
modified the form and implemented the view to display selected users
nishanth
parents:
92
diff
changeset
|
121 |
return render_to_response("sent_wsp_confirm.html", {"selected_users":selected_users}) |
505989755cd8
modified the form and implemented the view to display selected users
nishanth
parents:
92
diff
changeset
|
122 |
else: |
505989755cd8
modified the form and implemented the view to display selected users
nishanth
parents:
92
diff
changeset
|
123 |
return render_to_response("send_workshop_confirm.html", {"matches":matches}) |
86 | 124 |
else: |
93
505989755cd8
modified the form and implemented the view to display selected users
nishanth
parents:
92
diff
changeset
|
125 |
return render_to_response("send_workshop_confirm.html", {"matches":matches}) |
86 | 126 |
|
95
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
127 |
def confirm_wsp_participation(request, uid): |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
128 |
""" match id versus email and take lappy details. |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
129 |
""" |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
130 |
|
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
131 |
if request.method == "POST": |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
132 |
pass |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
133 |
else: |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
134 |
try: |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
135 |
email = request.GET['email'] |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
136 |
except MultiValueDictKeyError: |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
137 |
raise Http404 |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
138 |
|
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
139 |
try: |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
140 |
Registrant.objects.get(id=uid, email=email) |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
141 |
except Registrant.DoesNotExist: |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
142 |
raise Http404 |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
143 |
|
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
144 |
return render_to_response("cnf_wsp_ptc.html", {"email":email}) |
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
145 |
|
ab554d46fd34
created basic view for confirmation of wsp participation
nishanth
parents:
93
diff
changeset
|
146 |
|
67 | 147 |
def admin_login(request): |
148 |
""" basic login. |
|
149 |
""" |
|
56 | 150 |
|
72 | 151 |
redirect_url = "/%s/registration/stats"%aup |
152 |
||
153 |
user = request.user |
|
154 |
if user.is_authenticated(): |
|
155 |
return redirect(redirect_url) |
|
156 |
||
67 | 157 |
if request.method == "POST": |
158 |
form = LoginForm(request.POST) |
|
159 |
if form.is_valid(): |
|
72 | 160 |
data = form.cleaned_data |
67 | 161 |
|
162 |
username = data['username'] |
|
163 |
password = data['password'] |
|
164 |
||
165 |
user = authenticate(username=username, password=password) |
|
166 |
login(request, user) |
|
72 | 167 |
return redirect(redirect_url) |
67 | 168 |
else: |
169 |
return render_to_response("login.html", {"form":form}) |
|
170 |
else: |
|
171 |
form = LoginForm() |
|
172 |
return render_to_response("login.html", {"form":form}) |
|
173 |
||
70 | 174 |
@login_required |
67 | 175 |
def admin_logout(request): |
176 |
""" simply logout. |
|
177 |
""" |
|
178 |
||
179 |
logout(request) |
|
180 |
return render_to_response("logout.html") |
|
56 | 181 |
|
26
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
182 |
def homepage(request): |
91 | 183 |
return render_to_response("index.html") |
26
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
184 |
|
31 | 185 |
def schedule(request): |
91 | 186 |
return render_to_response("schedule.html") |
31 | 187 |
|
188 |
def organizers(request): |
|
91 | 189 |
return render_to_response("organizers.html") |
31 | 190 |
|
191 |
def venue(request): |
|
91 | 192 |
return render_to_response("about_venue.html") |
31 | 193 |
|
194 |
def contact(request): |
|
91 | 195 |
return render_to_response("contact.html") |
31 | 196 |
|
197 |
def about(request): |
|
91 | 198 |
return render_to_response("about.html") |
48
a3e6f9470549
made some changes to links and added accomodation page.
anoop
parents:
31
diff
changeset
|
199 |
|
a3e6f9470549
made some changes to links and added accomodation page.
anoop
parents:
31
diff
changeset
|
200 |
def accomodation(request): |
91 | 201 |
return render_to_response("accomodation.html") |
84 | 202 |
|
203 |
def about_mumbai(request): |
|
204 |
return render_to_response("about_mumbai.html") |
|
205 |
||
206 |
def reaching_iitb(request): |
|
207 |
return render_to_response("reaching_iitb.html") |
|
91 | 208 |
|
209 |
def talks_proposed(request): |
|
210 |
return render_to_response("talks_proposed.html") |