Commit fe56165b authored by chris's avatar chris

Correctif: dates en désordre (bug 611)

parent 16e3ce0e
......@@ -19,6 +19,6 @@ def register(request):
def clear_cookie(request, poll_id):
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):
instances = OrderedItemFormset(request.POST, instance=poll)
if instances.is_valid():
for instance in instances.cleaned_data:
try:
this_choice = instance['choice']
if not instance.get('DELETE'):
......@@ -91,6 +90,12 @@ def editchoices(request, poll_id):
except (KeyError, Choice.DoesNotExist):
choice = Choice(poll=poll, choice=instance['choice'], details=instance['details'])
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:
try:
choice = Choice.objects.get(poll=poll,choice=this_choice)
......@@ -104,6 +109,7 @@ def editchoices(request, poll_id):
except:
pass
except:
# probably an empty datefield?
pass
redir = '/' + str(poll.id) + '/'
return HttpResponseRedirect(redir)
......
......@@ -89,12 +89,12 @@
</tr>
</thead>
<!-- vforms.management_form -->
{% for v in vforms.forms %}
<tr id="{{ v.prefix }}-row">
<td>
{{ v.management_form }}
{% for hidden in v.hidden_fields %} {{ hidden }} {% endfor %}
{% if v.instance.pk %}{{ v.DELETE }}{% endif %}
{{ v.choice.errors }}{{ v.choice }}
</td>
......
......@@ -24,7 +24,7 @@
<table>
<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>
{% endfor %}
<td></td>
......@@ -33,7 +33,7 @@
{% for bulletin in object.bulletin_set.all %}
<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>
{% endfor %}
......@@ -43,7 +43,7 @@
<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>
{% 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