diff options
| author | etienne <etienne@07715635-78ed-41b0-aaf1-0afda6c37f35> | 2008-12-07 20:53:20 +0000 |
|---|---|---|
| committer | etienne <etienne@07715635-78ed-41b0-aaf1-0afda6c37f35> | 2008-12-07 20:53:20 +0000 |
| commit | a0e093c353140308fc2fac24f1ec179e304ab3ba (patch) | |
| tree | 7171188f2b9d4004d9346b313a02852b3c82eaff /polls/views.py | |
| parent | be9608d21e785ac9e2096f3753ebadbdbfa8f780 (diff) | |
| download | Papillon-a0e093c353140308fc2fac24f1ec179e304ab3ba.tar.bz2 Papillon-a0e093c353140308fc2fac24f1ec179e304ab3ba.zip | |
Comments
Diffstat (limited to 'polls/views.py')
| -rw-r--r-- | polls/views.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/polls/views.py b/polls/views.py index 0ab23b7..f42f854 100644 --- a/polls/views.py +++ b/polls/views.py @@ -31,7 +31,8 @@ from django.shortcuts import render_to_response from django.http import HttpResponseRedirect from papillon.settings import LANGUAGES -from papillon.polls.models import Poll, PollUser, Choice, Voter, Vote, Category +from papillon.polls.models import Poll, PollUser, Choice, Voter, Vote, \ + Category, Comment def getBaseResponse(request): """Manage basic fields for the template @@ -364,6 +365,15 @@ def poll(request, poll_url): # a new choice v = Vote(voter=voter, choice=choice, value=0) v.save() + def newComment(request, poll): + "Comment the poll" + if 'comment_author' not in request.POST \ + or not request.POST['comment_author'] \ + or not request.POST['comment']: + return + c = Comment(poll=poll, author_name=request.POST['comment_author'], + text=request.POST['comment']) + c.save() def newVote(request, choices): "Create new votes" @@ -449,6 +459,9 @@ def poll(request, poll_url): newVote(request, choices) # update the modification date of the poll poll.save() + if 'comment' in request.POST and poll.open: + # comment posted + newComment(request, poll) # 'voter' is in request.GET when the edit button is pushed if 'voter' in request.GET and poll.open: @@ -501,6 +514,7 @@ def poll(request, poll_url): choice.save() response_dct['voters'] = voters response_dct['choices'] = choices + response_dct['comments'] = Comment.objects.filter(poll=poll) # verify if vote's result has to be displayed response_dct['hide_vote'] = True if u'display_result' in request.GET: |
