now selecting users through forms. created a form for that anoop
authornishanth
Wed, 14 Jul 2010 20:47:37 +0530
branchanoop
changeset 90 1a6e1af98624
parent 89 b8fc66038d0d
child 92 9f305face605
now selecting users through forms. created a form for that
sdi/forms.py
sdi/views.py
templates/send_workshop_confirm.html
--- a/sdi/forms.py	Wed Jul 14 20:20:33 2010 +0530
+++ b/sdi/forms.py	Wed Jul 14 20:47:37 2010 +0530
@@ -168,3 +168,11 @@
 
         return username
 
+def UserSelectForm(users):
+
+    choices = [ (_.id, _.first_name) for _ in users ]
+    class myF(forms.Form):
+
+        selected_users = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=choices, required=False)
+
+    return myF()
--- a/sdi/views.py	Wed Jul 14 20:20:33 2010 +0530
+++ b/sdi/views.py	Wed Jul 14 20:47:37 2010 +0530
@@ -5,7 +5,7 @@
 from django.contrib.auth import authenticate, login, logout
 
 from sage_days.sdi.models import Registrant
-from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm
+from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm, UserSelectForm
 from sage_days.sdi.events import send_reg_complete_mail, mail_invi
 from sage_days.settings import APACHE_URL_PREFIX as aup
 
@@ -117,7 +117,8 @@
     if request.method == "POST":
         pass
     else:
-        return render_to_response("send_workshop_confirm.html", {"matches":matches}) 
+        form = UserSelectForm(matches)
+        return render_to_response("send_workshop_confirm.html", {"form":form}) 
 
 def admin_login(request):
     """ basic login.
--- a/templates/send_workshop_confirm.html	Wed Jul 14 20:20:33 2010 +0530
+++ b/templates/send_workshop_confirm.html	Wed Jul 14 20:47:37 2010 +0530
@@ -3,7 +3,8 @@
 Workshop Confirmaton Mail
 {% endblock %}
 {% block content %}
-{% for user in matches %}
-{{user}} <br />
-{% endfor %}
+<form action="" method=post>
+		{{ form.as_p }}
+		<input type=submit value=send />
+</form>
 {% endblock %}