added a form for commenting on tasks
authorNishanth Amuluru <nishanth@fossee.in>
Sun, 09 Jan 2011 00:52:35 +0530
changeset 347 d291c08c62de
parent 346 8ffc889a3b37
child 348 1eb24b1662cf
added a form for commenting on tasks
pytask/taskapp/forms.py
--- a/pytask/taskapp/forms.py	Sun Jan 09 00:30:08 2011 +0530
+++ b/pytask/taskapp/forms.py	Sun Jan 09 00:52:35 2011 +0530
@@ -1,5 +1,5 @@
 from django import forms
-from pytask.taskapp.models import Task, WorkReport
+from pytask.taskapp.models import Task, WorkReport, TaskComment
 
 class CreateTaskForm(forms.ModelForm):
     class Meta:
@@ -51,6 +51,21 @@
         except Task.DoesNotExist:
             return data
 
+class TaskCommentForm(forms.ModelForm):
+
+    class Meta:
+        model = TaskComment
+        fields = ['data']
+
+    def clean_data(self):
+
+        data = self.cleaned_data['data'].strip()
+        if not data:
+            raise forms.ValidationError("Please add some content")
+
+        return data
+
+
 def AddReviewerForm(choices,instance=None):
     """ return a form object with appropriate choices """