now empty comments will not be accepted.
authornishanth
Tue, 02 Mar 2010 15:03:48 +0530
changeset 176 13ceb76fd0a3
parent 175 10a488a6fbba
child 177 4a7206176345
now empty comments will not be accepted.
taskapp/views/task.py
templates/task/view.html
--- a/taskapp/views/task.py	Tue Mar 02 14:51:59 2010 +0530
+++ b/taskapp/views/task.py	Tue Mar 02 15:03:48 2010 +0530
@@ -104,7 +104,10 @@
    
     if request.method == 'POST':
         if not is_guest:
-            data = request.POST["data"]
+            data = request.POST.get("data", "").strip()
+            if not data:
+                context['error_msg'] = "Enter some message to comment"
+                return render_to_response('task/view.html', context)
             new_comment = Comment(task=task, data=data, created_by=user, creation_datetime=datetime.now())
             new_comment.save()
             return redirect(task_url)
--- a/templates/task/view.html	Tue Mar 02 14:51:59 2010 +0530
+++ b/templates/task/view.html	Tue Mar 02 15:03:48 2010 +0530
@@ -136,12 +136,15 @@
             {% for comment in comments %}
                 <a href="/user/view/uid={{comment.created_by.id}}">{{ comment.created_by.username }}</a> 
                 on {{ comment.creation_datetime|date:"D d M Y"}} at {{comment.creation_datetime|time:"H:i"}} wrote:<br />
-            {{ comment.data }}<br /><br />
+            {{ comment.data|linebreaksbr }}<br /><br />
             {% endfor %}
         {% endif %}
 
         {% if not is_guest %}
         <hr />
+        {% if error_msg %}
+            {{error_msg}}<br />
+        {% endif %}
             {% ifnotequal task.status "CM" %}
                 Add comment:<br />
                 <form action="" method="post">