sdi/views.py
branchanoop
changeset 160 2f01af211af9
parent 159 f2f389e688fb
child 161 c7c5c727a483
--- a/sdi/views.py	Wed Jul 21 17:37:52 2010 +0530
+++ b/sdi/views.py	Thu Jul 22 19:34:24 2010 +0530
@@ -121,16 +121,24 @@
     send a confirmation mail to them if not sent.
     """
 
-    matches = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_workshop="1")
-    if request.method == "POST":
-        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})
+    not_selected_ppl = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_workshop="1")
+    not_confirmed_ppl = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_workshop="2")
+    attending_ppl = Registrant.objects.filter(need_for_python_workshop=True, registrantinfo__status_of_attending_workshop="3")
+
+    choices = list(not_selected_ppl) + list(not_confirmed_ppl)
+    form = UserSelectForm(choices, request.POST)
+    if request.method == "POST" and form.is_valid():
+        selected_users = form.cleaned_data['selected_users']
+        for u in selected_users:
+            user_info = user.registrantinfo_set.all()[0]
+            user_info.status_of_attending_workshop = "2"
+            user_info.save()
+
+        return render_to_response("sent_wsp_confirm.html", {"selected_users":selected_users})
     else:
-        return render_to_response("send_workshop_confirm.html", {"matches":matches}) 
+        return render_to_response("send_wsp_cnf.html", {"attending": attending_ppl,
+                                                        "not_confirmed": not_confirmed_ppl,
+                                                        "not_selected": not_selected_ppl,})
 
 @login_required
 def send_sagedays_confirm(request):
@@ -192,9 +200,6 @@
                                                         "not_selected":not_selected_ppl,
                                                        })
 
-
-
-
 def confirm_wsp_participation(request, uid):
     """ match id versus email and take lappy details.
     """