Commit 6384a4a3 authored by chris's avatar chris

Meilleure approche pour ordonner les dates (mais pas encore les votes)

parent 057f182c
...@@ -24,7 +24,8 @@ class Choice(models.Model): ...@@ -24,7 +24,8 @@ class Choice(models.Model):
choice = models.DateField() choice = models.DateField()
details = models.CharField(max_length=200,blank=True) details = models.CharField(max_length=200,blank=True)
votecount = models.IntegerField(default=0,blank=True) votecount = models.IntegerField(default=0,blank=True)
class Meta:
ordering = ['choice']
def __unicode__(self): def __unicode__(self):
return str(self.choice) # hacky? return str(self.choice) # hacky?
......
...@@ -153,7 +153,7 @@ def vote(request, poll_id): ...@@ -153,7 +153,7 @@ def vote(request, poll_id):
if request.method == 'POST': if request.method == 'POST':
form = BulletinForm(request.POST,initial={'poll': poll.id,}) form = BulletinForm(request.POST,initial={'poll': poll.id,})
vforms = [ [VoteForm(request.POST, prefix=choice) ] for choice in Choice.objects.filter(poll=poll.id).order_by('choice') ] vforms = [ [VoteForm(request.POST, prefix=choice) ] for choice in Choice.objects.filter(poll=poll.id) ]
if form.is_valid(): if form.is_valid():
if request.user.is_authenticated(): if request.user.is_authenticated():
...@@ -233,7 +233,7 @@ def vote(request, poll_id): ...@@ -233,7 +233,7 @@ def vote(request, poll_id):
vforms = [ [ VoteForm(initial={'choice': choice,'voice': True,}, prefix=choice) ] for choice in Choice.objects.filter(poll=poll_id) ] vforms = [ [ VoteForm(initial={'choice': choice,'voice': True,}, prefix=choice) ] for choice in Choice.objects.filter(poll=poll_id) ]
else: else:
# Default formset for unknown user # Default formset for unknown user
vforms = [ [ VoteForm(initial={'choice': choice,}, prefix=choice) ] for choice in Choice.objects.filter(poll=poll_id).order_by('choice') ] vforms = [ [ VoteForm(initial={'choice': choice,}, prefix=choice) ] for choice in Choice.objects.filter(poll=poll_id) ]
if request.user.is_authenticated(): if request.user.is_authenticated():
voter = str(request.user) voter = str(request.user)
try: try:
......
...@@ -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|dictsort:'choice' %} {% for choice in object.choice_set.all %}
<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>
...@@ -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|dictsort:'choice' %} {% for choice in object.choice_set.all %}
<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