Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
radiopanik
panikdb
Commits
04b00b9f
Commit
04b00b9f
authored
Apr 19, 2016
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add page to view vote result
parent
8c9bb862
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
1 deletion
+50
-1
panikdb/poll/views.py
panikdb/poll/views.py
+18
-0
panikdb/templates/vote_results.html
panikdb/templates/vote_results.html
+30
-0
panikdb/urls.py
panikdb/urls.py
+2
-1
No files found.
panikdb/poll/views.py
View file @
04b00b9f
from
django.contrib.auth.decorators
import
login_required
from
django.shortcuts
import
redirect
from
django.views.generic.base
import
TemplateView
from
django.views.generic.list
import
ListView
from
django.contrib
import
messages
from
.models
import
Vote
...
...
@@ -31,3 +32,20 @@ class VoteView(TemplateView):
return
redirect
(
'home'
)
vote
=
login_required
(
VoteView
.
as_view
())
class
ResultsView
(
ListView
):
model
=
Vote
template_name
=
'vote_results.html'
def
get_queryset
(
self
):
return
Vote
.
objects
.
order_by
(
'?'
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ResultsView
,
self
).
get_context_data
(
**
kwargs
)
context
[
'choice_1'
]
=
self
.
get_queryset
().
filter
(
choice
=
"1"
).
count
()
context
[
'choice_2'
]
=
self
.
get_queryset
().
filter
(
choice
=
"2"
).
count
()
context
[
'choice_3'
]
=
self
.
get_queryset
().
filter
(
choice
=
"3"
).
count
()
return
context
vote_results
=
login_required
(
ResultsView
.
as_view
())
panikdb/templates/vote_results.html
0 → 100644
View file @
04b00b9f
{% extends "base.html" %}
{% block content %}
<h2>
Résultats
</h2>
{% for vote in object_list %}
<div
style=
"padding: 1ex; border-bottom: 1px solid #888;"
>
{% if vote.choice == "1" %}
<img
src=
"/static/poll/Panik_2016_32.jpg"
height=
"250"
alt=
"logo 1"
/>
{% endif %}
{% if vote.choice == "2" %}
<img
src=
"/static/poll/Panik_2016_33.jpg"
height=
"250"
alt=
"logo 1"
/>
{% endif %}
{% if vote.choice == "3" %}
<div
style=
"display: table-cell; vertical-align: middle; height: 250px;"
>
Abstention
</div>
{% endif %}
{% if vote.comment %}
<pre
style=
"margin-top: 1em; font-family: sans-serif;"
>
{{vote.comment}}
</pre>
{% endif %}
</div>
{% endfor %}
<div
style=
"border-top: 1px solid #888; padding: 1ex;"
>
Totaux :
<ul>
<li>
1: {{choice_1}}
</li>
<li>
2: {{choice_2}}
</li>
<li>
3: {{choice_3}}
</li>
</ul>
</div>
{% endblock %}
panikdb/urls.py
View file @
04b00b9f
...
...
@@ -69,7 +69,8 @@ urlpatterns = patterns('',
url
(
r
'^combok/soundfiles/'
,
'panikombo.views.soundfiles'
),
url
(
r
'^combok/episodes/'
,
'panikombo.views.episodes'
),
url
(
r
'^vote/'
,
'panikdb.poll.views.vote'
,
name
=
'vote'
),
url
(
r
'^vote/$'
,
'panikdb.poll.views.vote'
,
name
=
'vote'
),
url
(
r
'^vote/results/$'
,
'panikdb.poll.views.vote_results'
,
name
=
'vote-results'
),
url
(
r
'^admin/'
,
include
(
admin
.
site
.
urls
)),
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment