taskapp/forms/user.py
changeset 141 2489392ffb56
parent 47 4e059a4220cc
child 206 85660d75683d
--- a/taskapp/forms/user.py	Sun Feb 28 10:43:36 2010 +0530
+++ b/taskapp/forms/user.py	Sun Feb 28 13:25:24 2010 +0530
@@ -2,11 +2,10 @@
 
 from django import forms
 from pytask.taskapp.models import GENDER_CHOICES, Profile
-from django.forms import ModelForm
 from registration.forms import RegistrationFormUniqueEmail
 from registration.models import RegistrationProfile
 
-class UserProfileEditForm(ModelForm):
+class UserProfileEditForm(forms.ModelForm):
     """Form used to edit the profile of a user"""
     
     class Meta:
@@ -26,3 +25,11 @@
         new_profile.save()
         
         return new_user
+
+def UserChoiceForm(choices, instance=None):
+    """ take a list of users and return a choice form.
+    """
+
+    class myForm(forms.Form):
+        user = forms.ChoiceField(choices, required=True)
+    return myForm(instance) if instance else myForm()