29 """ |
29 """ |
30 |
30 |
31 if request.method == "POST": |
31 if request.method == "POST": |
32 form = SearchForm(request.POST) |
32 form = SearchForm(request.POST) |
33 if form.is_valid(): |
33 if form.is_valid(): |
34 pass |
34 data = form.cleaned_data |
|
35 need_workshop = data['need_for_python_workshop'] |
|
36 db_query = "Registrant.objects.filter(need_for_python_workshop=%s)"%need_workshop |
|
37 |
|
38 topics_include, topics_exclude = data['topics_interested'] |
|
39 for number in topics_include: |
|
40 db_query += '.filter(topics_interested__contains="%s")'%number |
|
41 |
|
42 for number in topics_exclude: |
|
43 db_query += '.exclude(topics_interested__contains="%s")'%number |
|
44 |
|
45 start_python, stop_python = data['knowledge_of_python'] |
|
46 if start_python and stop_python: |
|
47 db_query += '.filter(knowledge_of_python__gte="%s")'%start_python |
|
48 db_query += '.filter(knowledge_of_python__lte="%s")'%stop_python |
|
49 elif start_python: |
|
50 db_query += '.filter(knowledge_of_python__exact="%s")'%start_python |
|
51 |
|
52 start_sage, stop_sage = data['knowledge_of_sage'] |
|
53 if start_sage and stop_sage: |
|
54 db_query += '.filter(knowledge_of_sage__gte="%s")'%start_sage |
|
55 db_query += '.filter(knowledge_of_sage__lte="%s")'%stop_sage |
|
56 elif start_sage: |
|
57 db_query += '.filter(knowledge_of_sage__exact="%s")'%start_sage |
|
58 |
|
59 start_likeliness, stop_likeliness = data['likeliness_of_attending'] |
|
60 if start_likeliness and stop_likeliness: |
|
61 db_query += '.filter(likeliness_of_attending__gte="%s")'%start_likeliness |
|
62 db_query += '.filter(likeliness_of_attending__lte="%s")'%stop_likeliness |
|
63 elif start_likeliness: |
|
64 db_query += '.filter(likeliness_of_attending__exact="%s")'%start_likeliness |
|
65 |
|
66 matches = eval(db_query) |
|
67 return render_to_response("list_stats.html", {"form":form, 'matches':matches}) |
35 else: |
68 else: |
36 return render_to_response("list_stats.html", {"form":form}) |
69 return render_to_response("list_stats.html", {"form":form}) |
37 else: |
70 else: |
38 form = SearchForm() |
71 form = SearchForm() |
39 return render_to_response("list_stats.html", {"form":form}) |
72 return render_to_response("list_stats.html", {"form":form}) |