--- a/sdi/forms.py Wed Jul 14 21:04:59 2010 +0530
+++ b/sdi/forms.py Thu Jul 15 01:06:32 2010 +0530
@@ -168,11 +168,16 @@
return username
-def UserSelectForm(users):
+def UserSelectForm(users, post_data=None ):
choices = [ (_.id, _.first_name) for _ in users ]
class myF(forms.Form):
selected_users = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=choices, required=False)
- return myF()
+ def clean_selected_users(self):
+ selected_ids = self.cleaned_data['selected_users']
+ return [ Registrant.objects.get(id=_) for _ in selected_ids ]
+
+ return myF(post_data) if post_data else myF()
+
--- a/sdi/views.py Wed Jul 14 21:04:59 2010 +0530
+++ b/sdi/views.py Thu Jul 15 01:06:32 2010 +0530
@@ -115,10 +115,14 @@
matches = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_workshop="1")
if request.method == "POST":
- pass
+ form = UserSelectForm(matches, request.POST)
+ if form.is_valid():
+ selected_users = form.cleaned_data['selected_users']
+ return render_to_response("sent_wsp_confirm.html", {"selected_users":selected_users})
+ else:
+ return render_to_response("send_workshop_confirm.html", {"matches":matches})
else:
- form = UserSelectForm(matches)
- return render_to_response("send_workshop_confirm.html", {"form":form})
+ return render_to_response("send_workshop_confirm.html", {"matches":matches})
def admin_login(request):
""" basic login.
--- a/templates/send_workshop_confirm.html Wed Jul 14 21:04:59 2010 +0530
+++ b/templates/send_workshop_confirm.html Thu Jul 15 01:06:32 2010 +0530
@@ -4,7 +4,15 @@
{% endblock %}
{% block content %}
<form action="" method=post>
- {{ form.as_p }}
- <input type=submit value=send />
+<table cellspacing=2 cellpadding=2>
+{% for m in matches %}
+<tr>
+<td> <input type="checkbox" name="selected_users" value="{{m.id}}" id="id_selected_users_0" /> </td>
+<td> {{m.first_name}} </td>
+<td> {{m.gender}} </td>
+</tr>
+{% endfor %}
+</table>
+<input type=submit value=send />
</form>
{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/sent_wsp_confirm.html Thu Jul 15 01:06:32 2010 +0530
@@ -0,0 +1,13 @@
+{% extends 'base.html' %}
+{% block title %}
+Sent WSP Confirmation
+{% endblock %}
+{% block content %}
+Confirmation mail was sent to the following users
+<ul>
+{% for u in selected_users %}
+<li> {{u}} </li>
+{% endfor %}
+</ul>
+<a href="/sage_days/registration/send_wsp_cnf">Return to previous page</a>
+{% endblock %}