summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoretienne2008-12-07 16:38:26 +0000
committeretienne2008-12-07 16:38:26 +0000
commit80b30ee1f188824f411b2e84673008a8d1383e7a (patch)
tree05d99c950013d2f2b48198562665433f3d23de21
parent599c62e4e77aaa4898b9ba690e39b1102ac09a71 (diff)
Migration to sqlite - Hide results to new voters
-rw-r--r--polls/feeds.py4
-rw-r--r--polls/views.py12
-rw-r--r--static/styles.css8
-rw-r--r--templates/base.html2
-rw-r--r--templates/category.html2
-rw-r--r--templates/createOrEdit.html6
-rw-r--r--templates/main.html4
-rw-r--r--templates/vote.html19
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 %}
</div>
<div id="footer">
-<a href='http://redmine.peacefrogs.net/projects/show/papillon'>Papillon</a> - <a href='http://www.gnu.org/licenses/agpl.html'>Copyright</a> © 2008 <a href='http://redmine.peacefrogs.net/projects/show/papillon'>Papillon project</a>
+<a href='http://redmine.peacefrogs.net/projects/show/papillon'>Papillon</a> - <a href='http://www.gnu.org/licenses/gpl.html'>Copyright</a> © 2008 <a href='http://redmine.peacefrogs.net/projects/show/papillon'>Papillon project</a>
</div>
</div>
</body>
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 %}<h2>{%trans "Polls"%}</h2>{%endif%}
{% for poll in polls %}
<div class='poll-description'>
- <p><a href='/papillon/poll/{{poll.base_url}}'>{{poll.name}}</a></p>
+ <p><a href='http://{{root_url}}poll/{{poll.base_url}}'>{{poll.name}}</a></p>
<p>{{poll.description}}</p>
</div>
{% 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 @@
</tr>{% endif %}
<tr>
- <td><label for='poll_public'>{% trans "Public" %}</label></td>
+ <td><label for='poll_public'>{% trans "Visibility" %}</label></td>
<td colspan='2'>
<select name='poll_public'>
- <option value='1'{%if poll.public %} selected='selected'{%endif%}>{%trans "Yes"%}</option>
- <option value='0'{%if not poll.public %} selected='selected'{%endif%}>{%trans "No"%}</option>
+ <option value='0'{%if not poll.public %} selected='selected'{%endif%}>{%trans "Private"%}</option>
+ <option value='1'{%if poll.public %} selected='selected'{%endif%}>{%trans "Public"%}</option>
</select>
</td>
<td class='form_description'>{% trans "If the poll is public it is available on the main page" %}</td>
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 @@
<h2><a href='edit/0'>{%trans "Create a poll"%}</a></h2>
<p>{% trans "Create a new sondage for take a decision, find a date for a meeting, etc." %} <a href='edit/0'>{% trans "Create it!" %}</a></p>
-{% if polls %}<h2>{%trans "Polls"%}</h2>{%endif%}
+{% if polls %}<h2>{%trans "Public polls"%}</h2>{%endif%}
{% for poll in polls %}
<div class='poll-description'>
- <p><a href='/papillon/poll/{{poll.base_url}}'>{{poll.name}}</a></p>
+ <p><a href='poll/{{poll.base_url}}'>{{poll.name}}</a></p>
<p>{{poll.description}}</p>
</div>
{% 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 %}
- <h2>{{poll_type_name}} - {{poll.name}}</h2>
+ <h2>{%if poll.category %}{{poll.category.name}} - {%endif%}{{poll.name}}</h2>
{% if error %}<p class='alert'>{{ error }}</p>{% endif %}
{% if not poll.open %}<p class='alert'>{% trans "The current poll is closed."%}</p>{% endif %}
<p>{{ poll.description }}</p>
@@ -14,6 +14,7 @@
<td class='simple'></td>
{% for choice in choices %}<th>{{choice.name}}{% if choice.limit %} ({% trans "max" %} {{choice.limit}}){%endif%}</th>
{% endfor %}</tr>
+ {% if not hide_vote %}
{% for voter in voters %}<tr{% if voter.highlight %} class='highlighted_voter'{% endif %}>
{% ifequal current_voter_id voter.id %}
<input type='hidden' name='voter' value='{{voter.id}}'/>
@@ -52,8 +53,8 @@
{%endfor%}
{%endifequal%}
</tr>{%endfor%}
- {%if not current_voter_id%}
- {% if poll.open %}
+ {%endif%}
+ {%if not current_voter_id%}{% if poll.open %}
<tr>
<td class='simple'></td>
<td><input type='text' name='author_name'/></td>
@@ -73,13 +74,12 @@
{% endif %}
</td>{%endfor%}
</tr>
- {%endif%}
- {%endif%}
- <tr id='sum'>
+ {%endif%}{%endif%}
+ {% if not hide_vote %}<tr id='sum'>
<td class='simple'></td><th>{% trans "Sum" %}</th>
{% for choice in choices %}<td{%if choice.highlight %} class='highlight'{%endif%}>{{choice.sum}}</td>
{% endfor %}
- </tr>
+ </tr>{%endif%}
</table>
{% if poll.open %}
<input type='submit' value='{%if current_voter_id%}{% trans "Edit" %}{%else%}{% trans "Participate" %}{%endif%}'/>
@@ -87,7 +87,8 @@
</div>
<hr class='spacer'/>
</form>
- <div id='syndication'>
- {% trans "Remain informed of poll evolution:" %} <a href="/papillon/feeds/poll/{{poll.base_url}}/">{%trans "Syndication"%}</a>
+ <div class='footnote'>
+ {%if hide_vote%}<p>{% trans "You have already vote? You are enough wise not to be influenced by other votes? You can display result by clicking" %} <a href='?display_result=1'>{% trans "here" %}</a>.</p>{%else%}
+ <p>{% trans "Remain informed of poll evolution:" %} <a href="http://{{root_url}}feeds/poll/{{poll.base_url}}/">{%trans "Syndication"%}</a></p>{%endif%}
</div>
{% endblock %}