# HG changeset patch # User nishanth # Date 1279136192 -19800 # Node ID 505989755cd82e33077ccb8823373f66a728c643 # Parent 9f305face605e9148d96a6133a0275a332df2977 modified the form and implemented the view to display selected users diff -r 9f305face605 -r 505989755cd8 sdi/forms.py --- 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() + diff -r 9f305face605 -r 505989755cd8 sdi/views.py --- 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. diff -r 9f305face605 -r 505989755cd8 templates/send_workshop_confirm.html --- 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.as_p }} - + +{% for m in matches %} + + + + + +{% endfor %} +
{{m.first_name}} {{m.gender}}
+
{% endblock %} diff -r 9f305face605 -r 505989755cd8 templates/sent_wsp_confirm.html --- /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 + +Return to previous page +{% endblock %}