From f636310f42f4d714b9eee73b87643817567943b5 Mon Sep 17 00:00:00 2001
From: nishanth
Date: Tue, 2 Mar 2010 15:03:48 +0530
Subject: now empty comments will not be accepted.
---
taskapp/views/task.py | 5 ++++-
templates/task/view.html | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/taskapp/views/task.py b/taskapp/views/task.py
index 4438401..071f69b 100644
--- a/taskapp/views/task.py
+++ b/taskapp/views/task.py
@@ -104,7 +104,10 @@ def view_task(request, tid):
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)
diff --git a/templates/task/view.html b/templates/task/view.html
index 5e4184c..046d148 100644
--- a/templates/task/view.html
+++ b/templates/task/view.html
@@ -136,12 +136,15 @@
{% for comment in comments %}
{{ comment.created_by.username }}
on {{ comment.creation_datetime|date:"D d M Y"}} at {{comment.creation_datetime|time:"H:i"}} wrote:
- {{ comment.data }}
+ {{ comment.data|linebreaksbr }}
{% endfor %}
{% endif %}
{% if not is_guest %}