author | anoop |
Fri, 04 Jun 2010 19:00:02 +0530 | |
branch | anoop |
changeset 31 | ec540dfbfe78 |
parent 26 | 212fcba4459e |
child 48 | a3e6f9470549 |
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 |
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
3 |
|
7 | 4 |
|
5 |
from sage_days.sdi.models import Registrant |
|
24
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
6 |
from sage_days.sdi.forms import RegisterForm, SearchForm |
7 | 7 |
|
8 |
def register(request): |
|
9 |
""" The user register page. |
|
10 |
""" |
|
11 |
||
9 | 12 |
if request.method == "POST": |
14 | 13 |
form = RegisterForm(request.POST) |
14 |
if form.is_valid(): |
|
15 | 15 |
form.save() |
26
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
16 |
return redirect("/sage_days/registration/complete") |
14 | 17 |
else: |
18 |
return render_to_response("register.html", {"form":form}) |
|
9 | 19 |
else: |
20 |
form = RegisterForm() |
|
21 |
return render_to_response("register.html", {"form":form}) |
|
22 | 22 |
|
23 |
def reg_complete(request): |
|
24 |
""" Tell the registration is successful. |
|
25 |
""" |
|
26 |
||
27 |
return render_to_response("reg_complete.html") |
|
23 | 28 |
|
29 |
def list_stats(request): |
|
30 |
""" List the statiscs of registered participants. |
|
31 |
""" |
|
32 |
||
24
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
33 |
if request.method == "POST": |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
34 |
form = SearchForm(request.POST) |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
35 |
if form.is_valid(): |
25 | 36 |
data = form.cleaned_data |
37 |
need_workshop = data['need_for_python_workshop'] |
|
38 |
db_query = "Registrant.objects.filter(need_for_python_workshop=%s)"%need_workshop |
|
39 |
||
40 |
topics_include, topics_exclude = data['topics_interested'] |
|
41 |
for number in topics_include: |
|
42 |
db_query += '.filter(topics_interested__contains="%s")'%number |
|
43 |
||
44 |
for number in topics_exclude: |
|
45 |
db_query += '.exclude(topics_interested__contains="%s")'%number |
|
46 |
||
47 |
start_python, stop_python = data['knowledge_of_python'] |
|
48 |
if start_python and stop_python: |
|
49 |
db_query += '.filter(knowledge_of_python__gte="%s")'%start_python |
|
50 |
db_query += '.filter(knowledge_of_python__lte="%s")'%stop_python |
|
51 |
elif start_python: |
|
52 |
db_query += '.filter(knowledge_of_python__exact="%s")'%start_python |
|
53 |
||
54 |
start_sage, stop_sage = data['knowledge_of_sage'] |
|
55 |
if start_sage and stop_sage: |
|
56 |
db_query += '.filter(knowledge_of_sage__gte="%s")'%start_sage |
|
57 |
db_query += '.filter(knowledge_of_sage__lte="%s")'%stop_sage |
|
58 |
elif start_sage: |
|
59 |
db_query += '.filter(knowledge_of_sage__exact="%s")'%start_sage |
|
60 |
||
61 |
start_likeliness, stop_likeliness = data['likeliness_of_attending'] |
|
62 |
if start_likeliness and stop_likeliness: |
|
63 |
db_query += '.filter(likeliness_of_attending__gte="%s")'%start_likeliness |
|
64 |
db_query += '.filter(likeliness_of_attending__lte="%s")'%stop_likeliness |
|
65 |
elif start_likeliness: |
|
66 |
db_query += '.filter(likeliness_of_attending__exact="%s")'%start_likeliness |
|
67 |
||
68 |
matches = eval(db_query) |
|
69 |
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
|
70 |
else: |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
71 |
return render_to_response("list_stats.html", {"form":form}) |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
72 |
else: |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
73 |
form = SearchForm() |
f79be1dd4a22
added clean methods for each attribute in search form
nishanth
parents:
23
diff
changeset
|
74 |
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
|
75 |
|
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
76 |
def homepage(request): |
212fcba4459e
changed the app to work with apache + added base.html, and did needed changes.
anoop
parents:
25
diff
changeset
|
77 |
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
|
78 |
|
31 | 79 |
def schedule(request): |
80 |
return render_to_response("schedule.html") |
|
81 |
||
82 |
def organizers(request): |
|
83 |
return render_to_response("organizers.html") |
|
84 |
||
85 |
def venue(request): |
|
86 |
return render_to_response("venue.html") |
|
87 |
||
88 |
def contact(request): |
|
89 |
return render_to_response("contact.html") |
|
90 |
||
91 |
def about(request): |
|
92 |
return render_to_response("about.html") |