empty description for a task not allowed. white space around description trimmed.
authornishanth
Tue, 02 Mar 2010 15:34:51 +0530
changeset 178 106909df0c17
parent 177 4a7206176345
child 179 8d1fdb148c27
empty description for a task not allowed. white space around description trimmed.
taskapp/forms/task.py
--- a/taskapp/forms/task.py	Tue Mar 02 15:21:45 2010 +0530
+++ b/taskapp/forms/task.py	Tue Mar 02 15:34:51 2010 +0530
@@ -7,11 +7,26 @@
         fields = ['title', 'desc', 'tags_field', 'credits']
     #publish = forms.BooleanField(required=False)
 
+    def clean_desc(self):
+        data = self.cleaned_data['desc'].strip()
+        if not data:
+            raise forms.ValidationError("Enter some description for the task")
+
+        return data
+
 def EditTaskForm(task, instance=None):
     class myForm(forms.ModelForm):
         class Meta:
             model = Task
             fields = ['title', 'desc', 'tags_field', 'credits']
+
+        def clean_desc(self):
+            data = self.cleaned_data['desc'].strip()
+            if not data:
+                raise forms.ValidationError("Enter some description for the task")
+
+            return data
+
     data = {
         'title': task.title,
         'desc': task.desc,