taskapp/forms/task.py
changeset 165 8ea5bcf3bd01
parent 151 d0cb85ba462a
child 178 106909df0c17
--- a/taskapp/forms/task.py	Tue Mar 02 01:05:24 2010 +0530
+++ b/taskapp/forms/task.py	Tue Mar 02 02:12:57 2010 +0530
@@ -5,7 +5,20 @@
     class Meta:
         model = Task
         fields = ['title', 'desc', 'tags_field', 'credits']
-    publish = forms.BooleanField(required=False)
+    #publish = forms.BooleanField(required=False)
+
+def EditTaskForm(task, instance=None):
+    class myForm(forms.ModelForm):
+        class Meta:
+            model = Task
+            fields = ['title', 'desc', 'tags_field', 'credits']
+    data = {
+        'title': task.title,
+        'desc': task.desc,
+        'tags_field': task.tags_field,
+        'credits': task.credits,
+    }
+    return myForm(instance) if instance else myForm(data)
 
 def AddMentorForm(choices,instance=None):
     """ return a form object with appropriate choices """