summaryrefslogtreecommitdiff
path: root/papillon/polls
diff options
context:
space:
mode:
Diffstat (limited to 'papillon/polls')
-rw-r--r--papillon/polls/models.py4
-rw-r--r--papillon/polls/views.py3
2 files changed, 5 insertions, 2 deletions
diff --git a/papillon/polls/models.py b/papillon/polls/models.py
index f8b3b22..411e75f 100644
--- a/papillon/polls/models.py
+++ b/papillon/polls/models.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2008 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2008-2011 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
@@ -138,7 +138,7 @@ the poll/check this option to reopen it"))
class Comment(models.Model):
'''Comment for a poll'''
- poll = models.ForeignKey(Poll)
+ poll = models.ForeignKey(Poll, related_name='comments')
author_name = models.CharField(max_length=100)
text = models.CharField(max_length=1000)
date = models.DateTimeField(auto_now_add=True)
diff --git a/papillon/polls/views.py b/papillon/polls/views.py
index 75823be..1022f58 100644
--- a/papillon/polls/views.py
+++ b/papillon/polls/views.py
@@ -333,6 +333,8 @@ def poll(request, poll_url):
v.save()
def newComment(request, poll):
"Comment the poll"
+ if poll.comments.count() >= settings.MAX_COMMENT_NB:
+ return
if 'comment_author' not in request.POST \
or not request.POST['comment_author'] \
or not request.POST['comment']:
@@ -486,4 +488,5 @@ def poll(request, poll_url):
if 'knowned_vote_' + poll.base_url in request.session:
response_dct['hide_vote'] = False
response_dct['form_comment'] = CommentForm()
+ response_dct['max_comment_nb'] = settings.MAX_COMMENT_NB
return render_to_response('vote.html', response_dct)