Commit 2e622212 authored by Christophe Siraut's avatar Christophe Siraut

Respect minutes in datetimewidget. Auto fill last choice + 1 day.

parent 431c63b6
...@@ -7,7 +7,6 @@ from datetime import datetime ...@@ -7,7 +7,6 @@ from datetime import datetime
dateTimeOptions = { dateTimeOptions = {
'weekStart': '1', 'weekStart': '1',
'startView': '3', 'startView': '3',
'minView': '1',
'startDate': datetime.today().date(), 'startDate': datetime.today().date(),
'autoclose': 'true', 'autoclose': 'true',
'todayHighlight': 'true' 'todayHighlight': 'true'
......
...@@ -9,7 +9,7 @@ from django.template import RequestContext ...@@ -9,7 +9,7 @@ from django.template import RequestContext
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from .forms import UserProfileForm, PollForm, ChoiceForm, VoteForm, BulletinForm from .forms import UserProfileForm, PollForm, ChoiceForm, VoteForm, BulletinForm
from .models import Poll, Choice, Vote, Bulletin from .models import Poll, Choice, Vote, Bulletin
from datetime import timedelta
def email_notify(poll, voter): def email_notify(poll, voter):
"""Send email notification""" """Send email notification"""
...@@ -72,8 +72,12 @@ def editchoices(request, poll_id): ...@@ -72,8 +72,12 @@ def editchoices(request, poll_id):
_("There are some errors in the form you posted.")) _("There are some errors in the form you posted."))
if Choice.objects.filter(poll=poll_id).count() == 0: if Choice.objects.filter(poll=poll_id).count() == 0:
choiceFormset = get_formset(ChoiceForm, extra=2, can_delete=True) choiceFormset = get_formset(ChoiceForm, extra=1, can_delete=True)
formset = choiceFormset(instance=poll) formset = choiceFormset(instance=poll)
else:
last_choice = poll.choice_set.all().latest('choice').choice
proposal = last_choice + timedelta(days=1)
formset = choiceFormset(instance=poll, initial=[{'choice': proposal}])
return render(request, return render(request,
'meetingpoll/choice_form.html', 'meetingpoll/choice_form.html',
......
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