summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoretienne2009-12-04 22:58:19 +0000
committeretienne2009-12-04 22:58:19 +0000
commit6cab9442e9ada9c15879998d287bb549e2037238 (patch)
tree1cef34f4e5d752713f1ea215f49f1557768b8ff3
parent442d34494354cbca1cad022290db417ae7a7aede (diff)
Template cleaning - Vote page upgrade with new fonctionnality
-rw-r--r--locale/fr/LC_MESSAGES/django.po412
-rw-r--r--polls/forms.py25
-rw-r--r--polls/models.py16
-rw-r--r--polls/templatetags/__init__.py0
-rw-r--r--polls/templatetags/get_range.py25
-rw-r--r--polls/views.py20
-rw-r--r--templates/editChoicesAdmin.html10
-rw-r--r--templates/editChoicesUser.html10
-rw-r--r--templates/vote.html98
9 files changed, 359 insertions, 257 deletions
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po
index 274fe13..4d09e84 100644
--- a/locale/fr/LC_MESSAGES/django.po
+++ b/locale/fr/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-12-16 22:53+0100\n"
+"POT-Creation-Date: 2009-12-04 23:49+0100\n"
"PO-Revision-Date: 2008-08-20 00:22+0200\n"
"Last-Translator: Étienne Loks <etienne.loks@peacefrogs.net>,\n"
"Language-Team: fr\n"
@@ -20,237 +20,272 @@ msgstr ""
msgid "Papillon - poll : "
msgstr "Papillon - sondage : "
+#: polls/forms.py:99
+msgid "Invalid poll"
+msgstr "Sondage non valide"
+
+#: polls/forms.py:114
+msgid "Invalid date format: YYYY-MM-DD HH:MM:SS"
+msgstr "Format de date invalide AAAA-MM-JJ HH:MM:SS"
+
+#: polls/models.py:44 templates/edit.html:22
+msgid ""
+"Copy this address and send it to voters who want to participate to this poll"
+msgstr "Copiez cette adresse et envoyez là aux participants à ce sondage."
+
+#: polls/models.py:46 templates/edit.html:31
+msgid "Address to modify the current poll"
+msgstr "Adresse de modification de ce sondage"
+
+#: polls/models.py:48 templates/vote.html:133
+msgid "Author name"
+msgstr "Nom de l'auteur"
+
+#: polls/models.py:49
+msgid "Name, firstname or nickname of the author"
+msgstr "Nom, prénom ou surnom de l'auteur"
+
+#: polls/models.py:51
+msgid "Poll name"
+msgstr "Nom du sondage"
+
+#: polls/models.py:52
+msgid "Global name to present the poll"
+msgstr "Nom général pour présenter le sondage"
+
#: polls/models.py:54
-msgid "Poll"
-msgstr "Sondage"
+msgid "Poll description"
+msgstr "Description du sondage"
#: polls/models.py:55
-msgid "Balanced poll"
-msgstr "Sondage pondéré"
+msgid "Precise description of the poll"
+msgstr "Description précise du sondage"
+
+#: polls/models.py:57
+msgid "Yes/No poll"
+msgstr "Oui/Non"
-#: polls/models.py:56
+#: polls/models.py:58
+msgid "Yes/No/Maybe poll"
+msgstr "Oui/Non/Peut-être"
+
+#: polls/models.py:59
msgid "One choice poll"
msgstr "Sondage à choix unique"
-#: polls/models.py:113
+#: polls/models.py:60
+msgid "Valuable choice poll"
+msgstr "Sondage pondéré"
+
+#: polls/models.py:62
+msgid "Type of the poll"
+msgstr "Type du sondage"
+
+#: polls/models.py:63
+msgid ""
+"Type of the poll:\n"
+"\n"
+" - \"Yes/No poll\" is the appropriate type for a simple multi-choice poll\n"
+" - \"Yes/No/Maybe poll\" allows voters to stay undecided\n"
+" - \"One choice poll\" gives only one option to choose from\n"
+" - \"Valuable choice poll\" permit users to give a note between 0 to 9 to "
+"different choices\n"
+msgstr ""
+"Type du sondage :\n"
+"\n"
+" - \"Oui/Non\" est un sondage simple permettant de choisir entre plusieurs "
+"options\n"
+" - \"Oui/Non/Peut-être\" permet de laisser une option d'indécision aux "
+"votants\n"
+" - \"Sondage à choix unique\" ne permet que de choisir un choix parmi ceux "
+"proposés\n"
+" - \"Sondage pondéré\" permet aux utilisateurs de donner une note entre 0 et "
+"9 pour chaque choix\n"
+
+#: polls/models.py:71
+msgid "Choices are dates"
+msgstr "Les choix sont des dates"
+
+#: polls/models.py:72
+msgid "Check this option to choose between dates"
+msgstr "Cocher cette option pour choisir entre des dates"
+
+#: polls/models.py:74
+msgid "Closing date"
+msgstr "Date de fermeture"
+
+#: polls/models.py:74
+msgid "Closing date for participating to the poll"
+msgstr "Date de fermeture au vote du sondage"
+
+#: polls/models.py:78
+msgid "Display the poll on main page"
+msgstr "Afficher le sondage sur la page principale"
+
+#: polls/models.py:78
+msgid "Check this option to make the poll public"
+msgstr "Cocher cette option pour que le sondage soit publique"
+
+#: polls/models.py:81
+msgid "Allow users to add choices"
+msgstr "Permettre aux votants d'ajouter des choix"
+
+#: polls/models.py:81
+msgid "Check this option to open the poll to new choices submitted by users"
+msgstr ""
+"Cocher cette option pour permettre aux utilisateurs d'enrichir le sondage "
+"avec des nouveaux choix"
+
+#: polls/models.py:84
+msgid "Hide votes to new voters"
+msgstr "Cacher les résultats aux nouveaux votants"
+
+#: polls/models.py:84
+msgid "Check this option to hide poll results to new users"
+msgstr ""
+"Cocher cette option pour cacher, dans un premier temps, les résultats d'un "
+"sondage"
+
+#: polls/models.py:87
+msgid "State of the poll"
+msgstr "État du sondage"
+
+#: polls/models.py:87
+msgid "Uncheck this option to close the poll/check this option to reopen it"
+msgstr ""
+"Décocher cette option pour fermet le sondage aux votes/cocher cette option "
+"pour l'ouvrir de nouveau"
+
+#: polls/models.py:156
#, python-format
msgid "Vote from %(user)s"
msgstr "Vote de %(user)s"
-#: polls/models.py:167
+#: polls/models.py:224
msgid "Yes"
msgstr "Oui"
-#: polls/models.py:168 polls/models.py:169
+#: polls/models.py:225 polls/models.py:226
msgid "No"
msgstr "Non"
-#: polls/models.py:168
+#: polls/models.py:225
msgid "Maybe"
msgstr "Peut-être"
-#: polls/views.py:63
+#: polls/views.py:65
msgid "The poll requested don't exist (anymore?)"
msgstr "Le sondage que vous avez demandé n'existe pas (n'existe plus ?)"
-#: polls/views.py:97 templates/createOrEdit.html:26 templates/vote.html:100
-msgid "Author name"
-msgstr "Nom de l'auteur"
-
-#: polls/views.py:98 templates/createOrEdit.html:32
-msgid "Poll name"
-msgstr "Nom du sondage"
-
-#: polls/views.py:99 templates/createOrEdit.html:38
-msgid "Poll description"
-msgstr "Description du sondage"
-
-#: polls/views.py:100 templates/createOrEdit.html:77
-msgid "Poll type"
-msgstr "Type du sondage"
-
-#: polls/views.py:107
-#, python-format
-msgid "%s is a mandatory field"
-msgstr "%s est un champs obligatoire"
-
-#: polls/views.py:243
-#, python-format
-msgid ""
-"You cannot lower %(name)s's limit to this number : there is currently %(sum)"
-"d votes for this choice."
-msgstr ""
-"Vous ne pouvez limiter le vote de %(name)s à ce nombre : il y a actuellement "
-"%(sum)d votes pour ce choix."
-
-#: polls/views.py:250
-msgid "Non-numeric value for limit"
-msgstr "Valeur non numérique pour la limite"
-
#: templates/category.html:8
msgid "Polls"
msgstr "Sondage"
-#: templates/createOrEdit.html:6
-msgid ""
-"As long as no options were added to the poll, it will not be made available."
-msgstr ""
-"Tant qu'aucune option ne sera ajouté au sondage, il ne sera pas disponible."
-
-#: templates/createOrEdit.html:9
+#: templates/create.html:11
msgid "New poll"
msgstr "Nouveau sondage"
-#: templates/createOrEdit.html:9
+#: templates/create.html:28
+msgid "Create"
+msgstr "Créer"
+
+#: templates/edit.html:13
msgid "Edit poll"
msgstr "Éditer un sondage"
-#: templates/createOrEdit.html:14
+#: templates/edit.html:17
msgid "Poll url"
msgstr "Adresse du sondage"
-#: templates/createOrEdit.html:16
-msgid ""
-"Copy this address and send it to voters who want to participate to this poll"
-msgstr "Copiez cette adresse et envoyez là aux participants à ce sondage."
-
-#: templates/createOrEdit.html:19
+#: templates/edit.html:26
msgid "Administration url"
msgstr "Adresse d'administration"
-#: templates/createOrEdit.html:21
-msgid "Address to modify the current poll"
-msgstr "Adresse de modification de ce sondage"
-
-#: templates/createOrEdit.html:28
-msgid "Name, firstname or nickname of the author"
-msgstr "Nom, prénom ou surnom de l'auteur"
-
-#: templates/createOrEdit.html:34
-msgid "Global name to present the poll"
-msgstr "Nom général pour présenter le sondage"
-
-#: templates/createOrEdit.html:40
-msgid "Precise description of the poll"
-msgstr "Description précise du sondage"
+#: templates/edit.html:35
+msgid "Choices administration url"
+msgstr "Adresse d'administration des choix"
-#: templates/createOrEdit.html:44
-msgid "Poll status"
-msgstr "État du sondage"
+#: templates/edit.html:40
+msgid "Address to modify choices of the current poll."
+msgstr "Adresse de modification des choix disponibles pour ce sondage"
-#: templates/createOrEdit.html:47
-msgid "Open"
-msgstr "Ouvert"
+#: templates/edit.html:57 templates/editChoicesAdmin.html:38
+#: templates/vote.html:59 templates/vote.html.py:115
+msgid "Edit"
+msgstr "Modifier"
-#: templates/createOrEdit.html:48
-msgid "Closed"
-msgstr "Fermé"
+#: templates/editChoices.html:4
+msgid "New choice"
+msgstr "Nouveau choix"
-#: templates/createOrEdit.html:51
-msgid "Status of the poll. When closed no vote add or modification are allowed"
+#: templates/editChoices.html:11
+msgid ""
+"Setting a new choice. Optionally you can set a limit of vote for this "
+"choice. This limit is usefull for limited resources allocation."
msgstr ""
-"État du vote. Quand celui-ci est fermé aucun ajout ou modification de n'est "
-"permise"
-
-#: templates/createOrEdit.html:55
-msgid "Visibility"
-msgstr "Visibilité"
-
-#: templates/createOrEdit.html:58
-msgid "Private"
-msgstr "Restreinte"
-
-#: templates/createOrEdit.html:59
-msgid "Public"
-msgstr "Publique"
-
-#: templates/createOrEdit.html:62
-msgid "If the poll is public it is available on the main page"
-msgstr "Si le sondage est public, il est visible sur la page principale"
-
-#: templates/createOrEdit.html:66
-msgid "Poll category"
-msgstr "Catégorie du sondage"
-
-#: templates/createOrEdit.html:73
-msgid "Category of the poll"
-msgstr "La catégorie du sondage"
+"Ajouter un nouveau choix. Optionnellement vous pouvez ajouter une limite de "
+"vote pour ce choix. Cette limite est utile dans le cas d'attribution de "
+"ressources limitées."
-#: templates/createOrEdit.html:81
-msgid "Type of the poll:"
-msgstr "Type du sondage :"
+#: templates/editChoices.html:15 templates/editChoicesAdmin.html:35
+#: templates/editChoicesUser.html:22
+msgid "Limited to"
+msgstr "Limité à"
-#: templates/createOrEdit.html:83
-msgid "Meeting is the appropriate type to set a date for a meeting."
-msgstr "Réunion est le type adéquat pour trouver une date pour une réunion"
+#: templates/editChoices.html:15 templates/editChoicesAdmin.html:35
+#: templates/editChoicesUser.html:22
+msgid "vote(s)"
+msgstr "vote(s)"
-#: templates/createOrEdit.html:84
-msgid "\"Poll\" is the appropriate type for a simple multi-choice poll"
-msgstr "« Sondage » est le type adéquat pour un simple sondage à choix multiple"
+#: templates/editChoices.html:16
+msgid "Add"
+msgstr "Ajouter"
-#: templates/createOrEdit.html:85
-msgid "\"Balanced poll\" lets voters setting negative vote for some choices"
+#: templates/editChoicesAdmin.html:14
+msgid "As long as no options were added to the poll, it will not be available."
msgstr ""
-"« Sondage pondéré » permet aux participants de mettre des votes négatifs pour "
-"certains choix"
-
-#: templates/createOrEdit.html:86
-msgid "\"One choice poll\""
-msgstr "« Sondage à choix unique »"
+"Tant qu'aucune option ne sera ajouté au sondage, il ne sera pas disponible."
-#: templates/createOrEdit.html:94
-msgid "Create"
-msgstr "Créer"
+#: templates/editChoicesAdmin.html:16
+msgid "Complete/Finalise the poll"
+msgstr "Complète/Finalise le sondage"
-#: templates/createOrEdit.html:96 templates/createOrEdit.html.py:115
-#: templates/vote.html:42 templates/vote.html.py:85
-msgid "Edit"
-msgstr "Modifier"
+#: templates/editChoicesAdmin.html:17
+msgid "Next"
+msgstr "Suivant"
-#: templates/createOrEdit.html:103
-msgid "Choices"
-msgstr "Choix"
+#: templates/editChoicesAdmin.html:21
+msgid "Available choices"
+msgstr "Choix disponibles"
-#: templates/createOrEdit.html:107
+#: templates/editChoicesAdmin.html:24
msgid "Up/down"
msgstr "Haut/bas"
-#: templates/createOrEdit.html:107
+#: templates/editChoicesAdmin.html:25 templates/editChoicesUser.html:17
msgid "Label"
msgstr "Libellé"
-#: templates/createOrEdit.html:107
+#: templates/editChoicesAdmin.html:26 templates/editChoicesUser.html:18
msgid "Limit"
msgstr "Limite"
-#: templates/createOrEdit.html:107
+#: templates/editChoicesAdmin.html:27
msgid "Delete?"
msgstr "Supprimer ?"
-#: templates/createOrEdit.html:110 templates/createOrEdit.html.py:120
-msgid "Limited to"
-msgstr "Limité à"
-
-#: templates/createOrEdit.html:110 templates/createOrEdit.html.py:120
-msgid "vote(s)"
-msgstr "vote(s)"
+#: templates/editChoicesUser.html:13
+msgid "Return to the poll"
+msgstr "Retourner au sondage"
-#: templates/createOrEdit.html:120
-msgid "New choice"
-msgstr "Nouveau choix"
+#: templates/editChoicesUser.html:14
+msgid "Choices"
+msgstr "Choix"
-#: templates/createOrEdit.html:120
-msgid ""
-"Setting a new choice. Optionally you can set a limit of vote for this "
-"choice. This limit is usefull for limited resources allocation."
+#: templates/editChoicesUser.html:21 templates/vote.html:23
+#: templates/vote.html.py:144
+msgid "DATETIME_FORMAT"
msgstr ""
-"Ajouter un nouveau choix. Optionnellement vous pouvez ajouter une limite de "
-"vote pour ce choix. Cette limite est utile dans le cas d'attribution de "
-"ressources limitées."
-
-#: templates/createOrEdit.html:123
-msgid "Add"
-msgstr "Ajouter"
#: templates/main.html:6
msgid "Create a poll"
@@ -275,27 +310,31 @@ msgstr "Sondages publics"
msgid "Categories"
msgstr "Catégories"
-#: templates/vote.html:7
+#: templates/vote.html:15
msgid "The current poll is closed."
msgstr "Le sondage actuel est fermé"
-#: templates/vote.html:15
+#: templates/vote.html:23
msgid "max"
msgstr "max"
-#: templates/vote.html:39 templates/vote.html.py:73
+#: templates/vote.html:54 templates/vote.html.py:103
msgid "Limit reached"
msgstr "Limite atteinte"
-#: templates/vote.html:79
+#: templates/vote.html:109
msgid "Sum"
msgstr "Somme"
-#: templates/vote.html:85
+#: templates/vote.html:115
msgid "Participate"
msgstr "Participer"
-#: templates/vote.html:91
+#: templates/vote.html:122
+msgid "Add a new choice to this poll?"
+msgstr "Ajouter un nouveau choix à ce sondage ?"
+
+#: templates/vote.html:124
msgid ""
"You have already vote? You are enough wise not to be influenced by other "
"votes? You can display result by clicking"
@@ -303,34 +342,30 @@ msgstr ""
"Vous avez déjà voté ? Vous pensez être suffisament sage pour ne pas être "
"influencé par les autres votes ? Vous pouvez afficher le résultat en cliquant"
-#: templates/vote.html:91
+#: templates/vote.html:124
msgid "here"
msgstr "ici"
-#: templates/vote.html:92
+#: templates/vote.html:125
msgid "Remain informed of poll evolution:"
msgstr "Restez informé de l'évolution du sondage"
-#: templates/vote.html:92
+#: templates/vote.html:125
msgid "syndication"
msgstr "syndication"
-#: templates/vote.html:95
+#: templates/vote.html:128
msgid "Comments"
msgstr "Commentaires"
-#: templates/vote.html:104
+#: templates/vote.html:137
msgid "Comment"
msgstr "Commentaire"
-#: templates/vote.html:107
+#: templates/vote.html:140
msgid "Send"
msgstr "Envoyer"
-#: templates/vote.html:111
-msgid "DATETIME_FORMAT"
-msgstr ""
-
#: templates/feeds/poll_description.html:2
#, python-format
msgid "%(voter_name)s has added/modified a vote."
@@ -347,20 +382,3 @@ msgid_plural ": %(sum)s votes"
msgstr[0] " : %(sum)s vote"
msgstr[1] " : %(sum)s votes"
-#~ msgid "French"
-#~ msgstr "Français"
-
-#~ msgid "English"
-#~ msgstr "Anglais"
-
-#~ msgid "Limited to %(choice_limit)s vote(s)"
-#~ msgstr "Limité à %(choice_limit)s vote(s)"
-
-#~ msgid "Available"
-#~ msgstr "Disponible"
-
-#~ msgid "Disabled"
-#~ msgstr "Indisponible"
-
-#~ msgid "Meeting"
-#~ msgstr "Réunion"
diff --git a/polls/forms.py b/polls/forms.py
index 6ac97a1..3a151aa 100644
--- a/polls/forms.py
+++ b/polls/forms.py
@@ -27,7 +27,7 @@ from django import forms
from django.contrib.admin import widgets as adminwidgets
from django.utils.translation import gettext_lazy as _
-from papillon.polls.models import Poll, Category, Choice
+from papillon.polls.models import Poll, Category, Choice, Comment
from papillon import settings
class TextareaWidget(forms.Textarea):
@@ -51,6 +51,21 @@ class CreatePollForm(PollForm):
if not Category.objects.all():
exclude.append('category')
+class CommentForm(forms.ModelForm):
+ class Meta:
+ model = Comment
+ exclude = ['date',]
+ def __init__(self, *args, **kwargs):
+ super(CommentForm, self).__init__(*args, **kwargs)
+ self.fields['text'].widget = TextareaWidget()
+
+# workaround for SplitDateTime with required=False
+class SplitDateTimeJSField(forms.SplitDateTimeField):
+ def __init__(self, *args, **kwargs):
+ super(SplitDateTimeJSField, self).__init__(*args, **kwargs)
+ self.widget.widgets[0].attrs = {'class': 'vDateField'}
+ self.widget.widgets[1].attrs = {'class': 'vTimeField'}
+
class AdminPollForm(PollForm):
class Meta:
model = Poll
@@ -58,14 +73,14 @@ class AdminPollForm(PollForm):
'dated_choices', 'type']
if not Category.objects.all():
exclude.append('category')
- def __init__(self, *args, **kwargs):
- super(AdminPollForm, self).__init__(*args, **kwargs)
- self.fields['enddate'].widget = adminwidgets.AdminSplitDateTime()
+ enddate = SplitDateTimeJSField(widget=adminwidgets.AdminSplitDateTime(),
+ required=False, label=Poll._meta.get_field('enddate').verbose_name,
+ help_text=Poll._meta.get_field('enddate').help_text)
class ChoiceForm(forms.ModelForm):
class Meta:
model = Choice
- fields = ('name', 'limit', 'poll', 'order')
+ fields = ('name', 'limit', 'poll', 'order',)
def __init__(self, *args, **kwargs):
super(ChoiceForm, self).__init__(*args, **kwargs)
self.fields['poll'].widget = forms.HiddenInput()
diff --git a/polls/models.py b/polls/models.py
index f5b9cbb..f8b3b22 100644
--- a/polls/models.py
+++ b/polls/models.py
@@ -65,7 +65,7 @@ modify the current poll"))
- "Yes/No poll" is the appropriate type for a simple multi-choice poll
- "Yes/No/Maybe poll" allows voters to stay undecided
- "One choice poll" gives only one option to choose from
- - "Valuable choice poll" permit users to give a note between 0 to 10 to \
+ - "Valuable choice poll" permit users to give a note between 0 to 9 to \
different choices
"""))
dated_choices = models.BooleanField(verbose_name=_("Choices are dates"),
@@ -85,7 +85,7 @@ verbose_name=_("Hide votes to new voters"), help_text=_("Check this option to \
hide poll results to new users"))
open = models.BooleanField(default=True,
verbose_name=_("State of the poll"), help_text=_("Uncheck this option to close \
-the poll/check the poll to reopen it"))
+the poll/check this option to reopen it"))
def getTypeLabel(self):
idx = [type[0] for type in self.TYPE].index(self.type)
@@ -173,6 +173,18 @@ class Choice(models.Model):
class Meta:
ordering = ['order']
+ def get_date(self):
+ if not self.poll.dated_choices:
+ return self.name
+ return datetime.datetime.strptime(self.name, '%Y-%m-%d %H:%M:%S')
+
+ def set_date(self, value):
+ self._date = value
+ #if not self.poll.dated_choices:
+ # self.name = value
+ #self.name = datetime.strftime(value, '%Y-%m-%d %H:%M:%S')
+ date = property(get_date, set_date)
+
def getSum(self, balanced_poll=None):
'''Get the sum of votes for this choice'''
sum = 0
diff --git a/polls/templatetags/__init__.py b/polls/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/polls/templatetags/__init__.py
diff --git a/polls/templatetags/get_range.py b/polls/templatetags/get_range.py
new file mode 100644
index 0000000..b9d8328
--- /dev/null
+++ b/polls/templatetags/get_range.py
@@ -0,0 +1,25 @@
+from django.template import Library
+
+register = Library()
+
+@register.filter
+def get_range( value ):
+ """
+ Filter - returns a list containing range made from given value
+ Usage (in template):
+
+ <ul>{% for i in 3|get_range %}
+ <li>{{ i }}. Do something</li>
+{% endfor %}</ul>
+
+Results with the HTML:
+<ul>
+<li>0. Do something</li>
+<li>1. Do something</li>
+<li>2. Do something</li>
+</ul>
+
+Instead of 3 one may use the variable set in the views
+ """
+ return range(value)
+
diff --git a/polls/views.py b/polls/views.py
index 7abd3a3..fdbeb6e 100644
--- a/polls/views.py
+++ b/polls/views.py
@@ -34,7 +34,7 @@ from papillon.settings import LANGUAGES, BASE_SITE
from papillon.polls.models import Poll, PollUser, Choice, Voter, Vote, \
Category, Comment
from papillon.polls.forms import CreatePollForm, AdminPollForm, ChoiceForm, \
- DatedChoiceForm
+ DatedChoiceForm, CommentForm
def getBaseResponse(request):
"""Manage basic fields for the template
@@ -149,7 +149,7 @@ def editChoicesUser(request, poll_url):
if redirect:
return redirect
try:
- poll = Poll.objects.filter(poll_url=poll_url)[0]
+ poll = Poll.objects.filter(base_url=poll_url)[0]
except IndexError:
poll = None
if not poll or not poll.opened_admin:
@@ -234,8 +234,8 @@ def editChoices(request, response_dct, admin=False):
pass
choices = Choice.objects.filter(poll=poll).order_by('order')
for choice in choices:
- if poll.dated_choices:
- choice.name = datetime.strptime(choice.name, '%Y-%m-%d %H:%M:%S')
+ if admin and poll.dated_choices:
+ choice.name = choice.date
choice.form = Form(instance=choice)
response_dct['choices'] = choices
response_dct['form_new_choice'] = form
@@ -479,9 +479,11 @@ def poll(request, poll_url):
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:
- request.session['knowned_vote_' + poll.base_url] = 1
- if 'knowned_vote_' + poll.base_url in request.session:
- response_dct['hide_vote'] = False
+ response_dct['hide_vote'] = poll.hide_choices
+ if poll.hide_choices:
+ 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
+ response_dct['form_comment'] = CommentForm()
return render_to_response('vote.html', response_dct)
diff --git a/templates/editChoicesAdmin.html b/templates/editChoicesAdmin.html
index a668319..260d68c 100644
--- a/templates/editChoicesAdmin.html
+++ b/templates/editChoicesAdmin.html
@@ -19,7 +19,6 @@
{% include 'editChoices.html' %}
{% if choices %}
<h2>{% trans "Available choices" %}</h2>
-<form action="" method="post">
<table class='new_poll'>
<tr>
{%if not poll.dated_choices%}<th>{% trans "Up/down" %}</th>{%endif%}
@@ -27,7 +26,9 @@
<th>{% trans "Limit" %}</th>
<th>{% trans "Delete?"%}</th>
</tr>
- {% for choice in choices %}{{choice.form.poll}}{{choice.form.order}}<tr>
+ {% for choice in choices %}
+ <form action="" method="post">
+ {{choice.form.poll}}{{choice.form.order}}<tr>
{%if not poll.dated_choices%}<td><a href='?up_choice={{choice.id}}' class='arrow'>+</a>
/ <a href='?down_choice={{choice.id}}' class='arrow'>-</a></td>{%endif%}
<td>{{choice.form.name}}</td>
@@ -35,8 +36,9 @@
<td><input type='checkbox' name='delete_{{choice.id}}'/></td>
<td><input type='hidden' name='edit' value='{{choice.id}}'/></td>
<td><input type='submit' value='{% trans "Edit" %}' class='submit'/></td>
- </tr>{% endfor %}
+ </tr>
+ </form>{% endfor %}
</table>
-</form>{% endif %}
+{% endif %}
{% endblock %}
diff --git a/templates/editChoicesUser.html b/templates/editChoicesUser.html
index bec7384..4313ade 100644
--- a/templates/editChoicesUser.html
+++ b/templates/editChoicesUser.html
@@ -10,6 +10,7 @@
{% endblock %}
{% block content %}
+ <p><a href="http://{{root_url}}poll/{{poll.base_url}}/">{%trans "Return to the poll"%}</a></p>
<h2>{% trans "Choices" %}</h2>
{% if choices %}<table class='new_poll'>
<tr>
@@ -17,15 +18,10 @@
<th>{% trans "Limit" %}</th>
</tr>
{% for choice in choices %}<tr>
- <td>{{choice.name}}</td>
+ <td>{%if poll.dated_choices%}{{choice.date|date:_("DATETIME_FORMAT")}}{%else%}{{choice.name}}{%endif%}</td>
<td>{% if choice.limit %}{% trans "Limited to"%} {{choice.limit}} {% trans "vote(s)" %}{% endif %}</td>
</tr>{% endfor %}
- <tr>
- <td></td>
- <td><input type='hidden' name='edit' value='1'/>
- <input type='submit' value='{% trans "Edit" %}' class='submit'/></td>
- </tr>
</table>
-</form>{% endif %}
+{% endif %}
{% include 'editChoices.html' %}
{% endblock %}
diff --git a/templates/vote.html b/templates/vote.html
index fbfbf7c..31ba7b0 100644
--- a/templates/vote.html
+++ b/templates/vote.html
@@ -1,55 +1,78 @@
{% extends "base.html" %}
{% load i18n %}
+{% load get_range %}
+
+{% block fullscript %}
+<script type="text/javascript" src="http://{{root_url}}admin/jsi18n/"></script>
+<script type="text/javascript" src="http://{{root_url}}media/js/core.js"></script>
+<script type="text/javascript" src="http://{{root_url}}media/js/admin/RelatedObjectLookups.js"></script>
+{{ form_comment.media }}
+{% endblock %}
{% block content %}
<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>
+ <p>{{ poll.description|safe }}</p>
<form method='post' action='{{base_url}}'>
<div id='poll_table'>
<table id='poll'>
<tr>
<td class='simple'></td>
<td class='simple'></td>
- {% for choice in choices %}<th>{{choice.name}}{% if choice.limit %} ({% trans "max" %} {{choice.limit}}){%endif%}</th>
+ {% for choice in choices %}<th>{%if poll.dated_choices%}{{choice.date|date:_("DATETIME_FORMAT")}}{%else%}{{choice.name}}{%endif%}{% 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}}'/>
- <td class='simple'></td>
- <td><input type='text' name='author_name' value='{{voter.user.name}}'/></td>
- {% for vote in voter.votes %}<td>
+{% ifequal current_voter_id voter.id %}
+ <input type='hidden' name='voter' value='{{voter.id}}'/>
+ <td class='simple'></td>
+ <td><input type='text' name='author_name' value='{{voter.user.name}}'/></td>
+ {% for vote in voter.votes %}<td>
{% if vote.choice.available or vote.value %}
- {% ifequal poll.type 'P' %}
- <input type='checkbox' name='vote_{{vote.id}}'{%ifequal vote.value 1%} checked='checked'{%endifequal%}/>
- {% endifequal %}
- {% ifequal poll.type 'O' %}
- <input type='radio' name='vote' value='{{vote.id}}' {%ifequal vote.value 1%} checked='checked'{%endifequal%}/>
- {% endifequal %}
- {% ifequal poll.type 'B' %}
- <select name='vote_{{vote.id}}'>
+ {% ifequal poll.type 'P' %}
+ <input type='checkbox' name='vote_{{vote.id}}'{%ifequal vote.value 1%} checked='checked'{%endifequal%}/>
+ {% endifequal %}
+ {% ifequal poll.type 'O' %}
+ <input type='radio' name='vote' value='{{vote.id}}' {%ifequal vote.value 1%} checked='checked'{%endifequal%}/>
+ {% endifequal %}
+ {% ifequal poll.type 'B' %}
+ <select name='vote_{{vote.id}}'>
{% for vote_choice in VOTE %}
- <option value='{{vote_choice.0}}'{%ifequal vote.value vote_choice.0%} selected='selected'{%endifequal%}>{{vote_choice.1.1}}</option>
+ <option value='{{vote_choice.0}}'{%ifequal vote.value vote_choice.0%} selected='selected'{%endifequal%}>{{vote_choice.1.1}}</option>
{% endfor %}
- </select>
- {% endifequal %}
+ </select>
+ {% endifequal %}
+ {% ifequal poll.type 'V' %}
+ <select name='vote_{{vote.id}}'>
+ {% for vote_choice in 10|get_range %}
+ <option value='{{vote_choice}}'{%ifequal vote.value vote_choice%} selected='selected'{%endifequal%}>{{vote_choice}}</option>
+ {% endfor %}
+ </select>
+ {% endifequal %}
{% else %}
- {% trans "Limit reached" %}
+ {% trans "Limit reached" %}
{% endif %}
- </td>{%endfor%}
- {%else%}<td class='simple'>{% if poll.open %}<a href='?voter={{voter.id}}'>{% trans "Edit" %}</a>{%else%}&nbsp;{%endif%}</td>
- <td>{{voter.user.name}}</td>
- {% for vote in voter.votes %}<td class='{%ifequal vote.value 1%}OK{%else%}{%ifequal vote.value 0%}OKO{%else%}KO{%endifequal%}{%endifequal%}'>
- {%ifequal poll.type 'B'%}
- {%for VOT in VOTE%}
- {%ifequal VOT.0 vote.value%}{{VOT.1.1}}{%endifequal%}{%endfor%}
- {%else%}
- {%for VOT in VOTE%}
- {%ifequal VOT.0 vote.value%}{{VOT.1.0}}{%endifequal%}{%endfor%}
- {%endifequal%}
- </td>
+ </td>
+ {%endfor%}
+{%else%}
+ <td class='simple'>{% if poll.open %}<a href='?voter={{voter.id}}'>{% trans "Edit" %}</a>{%else%}&nbsp;{%endif%}</td>
+ <td>{{voter.user.name}}</td>
+ {% for vote in voter.votes %}
+ {% ifequal poll.type 'V' %}
+ <td class='{%ifequal vote.value 9%}OK{%else%}{%ifequal vote.value 0%}KO{%else%}OKO{%endifequal%}{%endifequal%}'>
+ {%if vote.value%}{{vote.value}}{%else%}0{%endif%}</td>
+ {% else %}
+ <td class='{%ifequal vote.value 1%}OK{%else%}{%ifequal vote.value 0%}OKO{%else%}KO{%endifequal%}{%endifequal%}'>
+ {%ifequal poll.type 'B'%}
+ {%for VOT in VOTE%}
+ {%ifequal VOT.0 vote.value%}{{VOT.1.1}}{%endifequal%}{%endfor%}
+ {%else%}
+ {%for VOT in VOTE%}
+ {%ifequal VOT.0 vote.value%}{{VOT.1.0}}{%endifequal%}{%endfor%}
+ {%endifequal%}
+ </td>
+ {% endifequal %}
{%endfor%}
{%endifequal%}
</tr>{%endfor%}
@@ -69,6 +92,13 @@
<option value='{{vote_choice.0}}'{%ifequal vote_choice.0 0%} selected='selected'{%endifequal%}>{{vote_choice.1.1}}</option>{% endfor %}
</select>
{% endifequal %}
+ {% ifequal poll.type 'V' %}
+ <select name='choice_{{choice.id}}'>
+ {% for vote_choice in 10|get_range %}
+ <option value='{{vote_choice}}'>{{vote_choice}}</option>
+ {% endfor %}
+ </select>
+ {% endifequal %}
{% else %}
{% trans "Limit reached" %}
{% endif %}
@@ -88,6 +118,8 @@
</div>
<hr class='spacer'/>
</form>
+ {%if poll.opened_admin%}
+ <p><a href="http://{{root_url}}editChoicesUser/{{poll.base_url}}/">{%trans "Add a new choice to this poll?"%}</a></p>{%endif%}
<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%}
@@ -110,7 +142,7 @@
</form>{%endif%}
<ul>{%for comment in comments%}
<li><p class='author'>{{comment.author_name}}, {{comment.date|date:_("DATETIME_FORMAT")}} :</p>
- <pre>{{comment.text}}</pre></li>{%endfor%}
+ {{comment.text|safe}}</li>{%endfor%}
</ul>
</div>{%endif%}
-{% endblock %} \ No newline at end of file
+{% endblock %}