sdi/forms.py
branchanoop
changeset 175 b48d4c18a0aa
parent 133 38b7bad92b5b
child 234 cf3de6d222ce
--- a/sdi/forms.py	Mon Jul 26 17:38:50 2010 +0530
+++ b/sdi/forms.py	Mon Jul 26 17:44:26 2010 +0530
@@ -187,3 +187,22 @@
     sprinted_already = forms.ChoiceField(choices=(("Yes","Yes"), ("No", "No")))
     will_sprint = forms.ChoiceField(choices=SPRINT_CHOICES)
                                          
+
+def SendAccoForm(users, post_data=None):
+
+    choices = [ (_.id, _.first_name) for _ in users ]
+    class myF(forms.Form):
+
+	message = forms.CharField(required=True)
+        selected_users = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=choices, required=False)
+
+        def clean_selected_users(self):
+            selected_ids = self.cleaned_data['selected_users']
+            return [ Registrant.objects.get(id=_) for _ in selected_ids ]
+
+	def clean_message(self):
+	    message = self.cleaned_data['message']
+	    return message.strip()
+
+    return myF(post_data) if post_data else myF()
+