author | nishanth |
Mon, 07 Jun 2010 15:20:11 +0530 | |
branch | anoop |
changeset 65 | 0ca63c964237 |
parent 57 | 03150449a049 |
child 67 | b9690fbf78af |
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 |
|
5 |
from sage_days.sdi.models import Registrant |
|
56 | 6 |
from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm |
7 |
from sage_days.sdi.events import send_reg_complete_mail, mail_invi |
|
7 | 8 |
|
9 |
def register(request): |
|
10 |
""" The user register page. |
|
11 |
""" |
|
12 |
||
9 | 13 |
if request.method == "POST": |
14 | 14 |
form = RegisterForm(request.POST) |
15 |
if form.is_valid(): |
|
15 | 16 |
form.save() |
53 | 17 |
|
18 |
data = form.cleaned_data |
|
19 |
first_name = data['first_name'] |
|
20 |
last_name = data['last_name'] |
|
21 |
email = data['email'] |
|
22 |
send_reg_complete_mail(email, first_name, last_name) |
|
23 |
||
26
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
24 |
return redirect("/sage_days/registration/complete") |
14 | 25 |
else: |
26 |
return render_to_response("register.html", {"form":form}) |
|
9 | 27 |
else: |
28 |
form = RegisterForm() |
|
29 |
return render_to_response("register.html", {"form":form}) |
|
22 | 30 |
|
31 |
def reg_complete(request): |
|
32 |
""" Tell the registration is successful. |
|
33 |
""" |
|
34 |
||
35 |
return render_to_response("reg_complete.html") |
|
23 | 36 |
|
65
0ca63c964237
now login is required for accessing stats and send_invi pages
nishanth
parents:
57
diff
changeset
|
37 |
@login_required |
23 | 38 |
def list_stats(request): |
39 |
""" List the statiscs of registered participants. |
|
40 |
""" |
|
41 |
||
24
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
42 |
if request.method == "POST": |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
43 |
form = SearchForm(request.POST) |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
44 |
if form.is_valid(): |
25 | 45 |
data = form.cleaned_data |
46 |
need_workshop = data['need_for_python_workshop'] |
|
47 |
db_query = "Registrant.objects.filter(need_for_python_workshop=%s)"%need_workshop |
|
48 |
||
49 |
topics_include, topics_exclude = data['topics_interested'] |
|
50 |
for number in topics_include: |
|
51 |
db_query += '.filter(topics_interested__contains="%s")'%number |
|
52 |
||
53 |
for number in topics_exclude: |
|
54 |
db_query += '.exclude(topics_interested__contains="%s")'%number |
|
55 |
||
56 |
start_python, stop_python = data['knowledge_of_python'] |
|
57 |
if start_python and stop_python: |
|
58 |
db_query += '.filter(knowledge_of_python__gte="%s")'%start_python |
|
59 |
db_query += '.filter(knowledge_of_python__lte="%s")'%stop_python |
|
60 |
elif start_python: |
|
61 |
db_query += '.filter(knowledge_of_python__exact="%s")'%start_python |
|
62 |
||
63 |
start_sage, stop_sage = data['knowledge_of_sage'] |
|
64 |
if start_sage and stop_sage: |
|
65 |
db_query += '.filter(knowledge_of_sage__gte="%s")'%start_sage |
|
66 |
db_query += '.filter(knowledge_of_sage__lte="%s")'%stop_sage |
|
67 |
elif start_sage: |
|
68 |
db_query += '.filter(knowledge_of_sage__exact="%s")'%start_sage |
|
69 |
||
70 |
start_likeliness, stop_likeliness = data['likeliness_of_attending'] |
|
71 |
if start_likeliness and stop_likeliness: |
|
72 |
db_query += '.filter(likeliness_of_attending__gte="%s")'%start_likeliness |
|
73 |
db_query += '.filter(likeliness_of_attending__lte="%s")'%stop_likeliness |
|
74 |
elif start_likeliness: |
|
75 |
db_query += '.filter(likeliness_of_attending__exact="%s")'%start_likeliness |
|
76 |
||
77 |
matches = eval(db_query) |
|
78 |
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
|
79 |
else: |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
80 |
return render_to_response("list_stats.html", {"form":form}) |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
81 |
else: |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
82 |
form = SearchForm() |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
83 |
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
|
84 |
|
65
0ca63c964237
now login is required for accessing stats and send_invi pages
nishanth
parents:
57
diff
changeset
|
85 |
@login_required |
56 | 86 |
def send_invi(request): |
87 |
""" Take a list of csv email addresses and send mails to them. |
|
88 |
""" |
|
89 |
||
90 |
if request.method == "POST": |
|
91 |
form = EmailForm(request.POST) |
|
92 |
if form.is_valid(): |
|
93 |
to_emails = form.cleaned_data['emails'] |
|
94 |
mail_invi(to_emails) |
|
95 |
return render_to_response("send_invi.html", {"emails":to_emails}) |
|
96 |
else: |
|
97 |
return render_to_response("send_invi.html", {"form":form}) |
|
98 |
else: |
|
57 | 99 |
form = EmailForm() |
56 | 100 |
return render_to_response("send_invi.html", {"form":form}) |
101 |
||
102 |
||
103 |
||
26
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
104 |
def homepage(request): |
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
105 |
return render_to_response("index.html") |
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
106 |
|
31 | 107 |
def schedule(request): |
108 |
return render_to_response("schedule.html") |
|
109 |
||
110 |
def organizers(request): |
|
111 |
return render_to_response("organizers.html") |
|
112 |
||
113 |
def venue(request): |
|
114 |
return render_to_response("venue.html") |
|
115 |
||
116 |
def contact(request): |
|
117 |
return render_to_response("contact.html") |
|
118 |
||
119 |
def about(request): |
|
120 |
return render_to_response("about.html") |
|
48
a3e6f9470549
made some changes to links and added accomodation page.
anoop
parents:
31
diff
changeset
|
121 |
|
a3e6f9470549
made some changes to links and added accomodation page.
anoop
parents:
31
diff
changeset
|
122 |
def accomodation(request): |
a3e6f9470549
made some changes to links and added accomodation page.
anoop
parents:
31
diff
changeset
|
123 |
return render_to_response("accomodation.html") |