Commit fe56165b authored by chris's avatar chris

Correctif: dates en désordre (bug 611)

parent 16e3ce0e
...@@ -19,6 +19,6 @@ def register(request): ...@@ -19,6 +19,6 @@ def register(request):
def clear_cookie(request, poll_id): def clear_cookie(request, poll_id):
request.session.clear() request.session.clear()
return HttpResponseRedirect(reverse('nuages.sondage.views.vote', args=(poll_id,))) return HttpResponseRedirect(reverse('sondage.views.vote', args=(poll_id,)))
...@@ -79,7 +79,6 @@ def editchoices(request, poll_id): ...@@ -79,7 +79,6 @@ def editchoices(request, poll_id):
instances = OrderedItemFormset(request.POST, instance=poll) instances = OrderedItemFormset(request.POST, instance=poll)
if instances.is_valid(): if instances.is_valid():
for instance in instances.cleaned_data: for instance in instances.cleaned_data:
try: try:
this_choice = instance['choice'] this_choice = instance['choice']
if not instance.get('DELETE'): if not instance.get('DELETE'):
...@@ -91,6 +90,12 @@ def editchoices(request, poll_id): ...@@ -91,6 +90,12 @@ def editchoices(request, poll_id):
except (KeyError, Choice.DoesNotExist): except (KeyError, Choice.DoesNotExist):
choice = Choice(poll=poll, choice=instance['choice'], details=instance['details']) choice = Choice(poll=poll, choice=instance['choice'], details=instance['details'])
choice.save() choice.save()
# If bulletins for this poll existed before edition
# add an 'false' vote child to them for newly created choice.
# This makes template computation easier
for bulletin in Bulletin.objects.filter(poll=poll):
nvote = Vote(choice=choice, bulletin=bulletin, voice=False)
nvote.save()
else: else:
try: try:
choice = Choice.objects.get(poll=poll,choice=this_choice) choice = Choice.objects.get(poll=poll,choice=this_choice)
...@@ -104,7 +109,8 @@ def editchoices(request, poll_id): ...@@ -104,7 +109,8 @@ def editchoices(request, poll_id):
except: except:
pass pass
except: except:
pass # probably an empty datefield?
pass
redir = '/' + str(poll.id) + '/' redir = '/' + str(poll.id) + '/'
return HttpResponseRedirect(redir) return HttpResponseRedirect(redir)
else: else:
......
...@@ -89,12 +89,12 @@ ...@@ -89,12 +89,12 @@
</tr> </tr>
</thead> </thead>
<!-- vforms.management_form -->
{% for v in vforms.forms %} {% for v in vforms.forms %}
<tr id="{{ v.prefix }}-row"> <tr id="{{ v.prefix }}-row">
<td> <td>
{{ v.management_form }} {% for hidden in v.hidden_fields %} {{ hidden }} {% endfor %}
{% if v.instance.pk %}{{ v.DELETE }}{% endif %} {% if v.instance.pk %}{{ v.DELETE }}{% endif %}
{{ v.choice.errors }}{{ v.choice }} {{ v.choice.errors }}{{ v.choice }}
</td> </td>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<table> <table>
<tr><td class='names'></td> <tr><td class='names'></td>
{% for choice in object.choice_set.all %} {% for choice in object.choice_set.all|dictsort:'choice' %}
<td class='cell' title="{{ choice.choice|date:"l d F"}}{{ choice.details }}" onmouseover="toggle_visibility('info-{{ choice }}');" onmouseout="toggle_visibility('info-{{ choice }}');"> {{ choice.choice|date:"d-m" }} </td> <td class='cell' title="{{ choice.choice|date:"l d F"}}{{ choice.details }}" onmouseover="toggle_visibility('info-{{ choice }}');" onmouseout="toggle_visibility('info-{{ choice }}');"> {{ choice.choice|date:"d-m" }} </td>
{% endfor %} {% endfor %}
<td></td> <td></td>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
{% for bulletin in object.bulletin_set.all %} {% for bulletin in object.bulletin_set.all %}
<tr ><td class='names'>{{ bulletin.voter }}</td> <tr ><td class='names'>{{ bulletin.voter }}</td>
{% for vote in bulletin.vote_set.all %} {% for vote in bulletin.vote_set.all|dictsort:'choice.choice' %}
<td class='cell' title="{{ vote.comment }}" onmouseover="toggle_visibility('info-{{ vote.choice }}');" onmouseout="toggle_visibility('info-{{ vote.choice }}');"><div class="{{ vote.voice }}">{% if vote.comment %} ° {% endif %}</div></td> <td class='cell' title="{{ vote.comment }}" onmouseover="toggle_visibility('info-{{ vote.choice }}');" onmouseout="toggle_visibility('info-{{ vote.choice }}');"><div class="{{ vote.voice }}">{% if vote.comment %} ° {% endif %}</div></td>
{% endfor %} {% endfor %}
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<tr><td class='names'></td> <tr><td class='names'></td>
{% for choice in object.choice_set.all %} {% for choice in object.choice_set.all|dictsort:'choice' %}
<td class='cell' title="{{ choice }}"> {{ choice.votecount }} </td> <td class='cell' title="{{ choice }}"> {{ choice.votecount }} </td>
{% endfor %} {% endfor %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment