From 80b30ee1f188824f411b2e84673008a8d1383e7a Mon Sep 17 00:00:00 2001 From: etienne Date: Sun, 7 Dec 2008 16:38:26 +0000 Subject: Migration to sqlite - Hide results to new voters --- polls/feeds.py | 4 ++-- polls/views.py | 12 +++++++++--- static/styles.css | 8 +++++++- templates/base.html | 2 +- templates/category.html | 2 +- templates/createOrEdit.html | 6 +++--- templates/main.html | 4 ++-- templates/vote.html | 19 ++++++++++--------- 8 files changed, 35 insertions(+), 22 deletions(-) diff --git a/polls/feeds.py b/polls/feeds.py index 8e86645..66e896a 100644 --- a/polls/feeds.py +++ b/polls/feeds.py @@ -42,13 +42,13 @@ class PollLatestEntries(Feed): def link(self, obj): if not obj: raise FeedDoesNotExist - return BASE_SITE + "papillon/poll/" + obj.base_url + return BASE_SITE + "/poll/" + obj.base_url def description(self, obj): return obj.description def item_link(self, voter): - url = "%spapillon/poll/%s_%d" % (BASE_SITE, voter.poll.base_url, + url = "%s/poll/%s_%d" % (BASE_SITE, voter.poll.base_url, time.mktime(voter.modification_date.timetuple())) return url diff --git a/polls/views.py b/polls/views.py index b81e393..e969a74 100644 --- a/polls/views.py +++ b/polls/views.py @@ -372,7 +372,8 @@ def poll(request, poll_url): if choice not in selected_choices: v = Vote(voter=voter, choice=choice, value=0) v.save() - + # results can now be displayed + request.session['knowned_vote_' + poll.base_url] = 1 response_dct, redirect = getBaseResponse(request) if redirect: return redirect @@ -414,8 +415,7 @@ def poll(request, poll_url): except ValueError: pass - response_dct.update({'poll_type_name':poll.getTypeLabel(), - 'poll':poll, + response_dct.update({'poll':poll, 'VOTE':Vote.VOTE,}) response_dct['base_url'] = "/".join(request.path.split('/')[:-2]) \ + '/%s/' % poll.base_url @@ -472,4 +472,10 @@ def poll(request, poll_url): choice.save() response_dct['voters'] = voters response_dct['choices'] = choices + # verify if vote's result has to be displayed + response_dct['hide_vote'] = True + if u'display_result' in request.GET: + request.session['knowned_vote_' + poll.base_url] = 1 + if 'knowned_vote_' + poll.base_url in request.session: + response_dct['hide_vote'] = False return render_to_response('vote.html', response_dct) diff --git a/static/styles.css b/static/styles.css index e95cd1e..421b93f 100644 --- a/static/styles.css +++ b/static/styles.css @@ -237,10 +237,16 @@ background-color:grey; color:white; } -#syndication{ +.footnote{ +font-size:10px; padding:10px; } +.footnote p{ +padding:0; +margin:2px; +} + .poll-description{ margin:4px; padding:4px; diff --git a/templates/base.html b/templates/base.html index 3a0b3b7..377cf28 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,7 +18,7 @@ {% block content %}{% endblock %} diff --git a/templates/category.html b/templates/category.html index f649565..7b26d48 100644 --- a/templates/category.html +++ b/templates/category.html @@ -8,7 +8,7 @@ {% if polls %}

{%trans "Polls"%}

{%endif%} {% for poll in polls %}
-

{{poll.name}}

+

{{poll.name}}

{{poll.description}}

{% endfor %} diff --git a/templates/createOrEdit.html b/templates/createOrEdit.html index 3e88bfe..033edec 100644 --- a/templates/createOrEdit.html +++ b/templates/createOrEdit.html @@ -52,11 +52,11 @@ {% endif %} - + {% trans "If the poll is public it is available on the main page" %} diff --git a/templates/main.html b/templates/main.html index 6c1e09d..43586f4 100644 --- a/templates/main.html +++ b/templates/main.html @@ -6,10 +6,10 @@

{%trans "Create a poll"%}

{% trans "Create a new sondage for take a decision, find a date for a meeting, etc." %} {% trans "Create it!" %}

-{% if polls %}

{%trans "Polls"%}

{%endif%} +{% if polls %}

{%trans "Public polls"%}

{%endif%} {% for poll in polls %}
-

{{poll.name}}

+

{{poll.name}}

{{poll.description}}

{% endfor %} diff --git a/templates/vote.html b/templates/vote.html index 803813e..21b8a0d 100644 --- a/templates/vote.html +++ b/templates/vote.html @@ -2,7 +2,7 @@ {% load i18n %} {% block content %} -

{{poll_type_name}} - {{poll.name}}

+

{%if poll.category %}{{poll.category.name}} - {%endif%}{{poll.name}}

{% if error %}

{{ error }}

{% endif %} {% if not poll.open %}

{% trans "The current poll is closed."%}

{% endif %}

{{ poll.description }}

@@ -14,6 +14,7 @@ {% for choice in choices %}{{choice.name}}{% if choice.limit %} ({% trans "max" %} {{choice.limit}}){%endif%} {% endfor %} + {% if not hide_vote %} {% for voter in voters %} {% ifequal current_voter_id voter.id %} @@ -52,8 +53,8 @@ {%endfor%} {%endifequal%} {%endfor%} - {%if not current_voter_id%} - {% if poll.open %} + {%endif%} + {%if not current_voter_id%}{% if poll.open %} @@ -73,13 +74,12 @@ {% endif %} {%endfor%} - {%endif%} - {%endif%} - + {%endif%}{%endif%} + {% if not hide_vote %} {% trans "Sum" %} {% for choice in choices %}{{choice.sum}} {% endfor %} - + {%endif%} {% if poll.open %} @@ -87,7 +87,8 @@
-
- {% trans "Remain informed of poll evolution:" %} {%trans "Syndication"%} +
+ {%if hide_vote%}

{% trans "You have already vote? You are enough wise not to be influenced by other votes? You can display result by clicking" %} {% trans "here" %}.

{%else%} +

{% trans "Remain informed of poll evolution:" %} {%trans "Syndication"%}

{%endif%}
{% endblock %} -- cgit v1.2.3