Commit 87e082ad authored by chris's avatar chris

meetingpoll/forms: work with lastest django-datetime-widget (9.3) which

brings backward incompatible changes.
parent 2aa64cde
......@@ -5,11 +5,14 @@ from datetime import datetime
from datetimewidget.widgets import DateTimeWidget
dateTimeOptions = {
'weekStart': '1',
'minView': '0',
'minuteStep': '15',
'startDate': datetime.today().date(),
'todayHighlight': 'true',
'weekStart': 1,
'minView': 0,
'minuteStep': 15,
'todayHighlight': True,
# Check https://github.com/asaglimbeni/django-datetime-widget/issues/62
# 'format': 'dd/mm/yyyy hh:ii'
# How do we get startDate?
# 'startDate': datetime.today(),
}
......@@ -19,16 +22,6 @@ class UserProfileForm(forms.ModelForm):
fields = ('email_notifications',)
class DateTimeWidgetFixed(DateTimeWidget):
def __init__(self, **kwargs):
super(DateTimeWidgetFixed, self).__init__(**kwargs)
def value_from_datadict(self, data, files, name):
a = str(super(
DateTimeWidgetFixed, self).value_from_datadict(data, files, name))
return a
class PollForm(forms.ModelForm):
title = forms.CharField(label=_('Title'))
description = forms.CharField(
......@@ -42,7 +35,10 @@ class PollForm(forms.ModelForm):
class ChoiceForm(forms.ModelForm):
choice = forms.DateTimeField(
widget=DateTimeWidgetFixed(
widget=DateTimeWidget(
#attrs={'id':"yourdatetimeid"},
usel10n = True,
bootstrap_version=2,
options=dateTimeOptions)
)
......
......@@ -25,8 +25,8 @@ class MeetingPoll(WebTest):
self.assertEqual(response.status_code, 404)
def test_poll_creation(self):
# Gerald wants to create a poll
# He forget to fill the form title
# Anne wants to create a poll
# She forget to fill the form title
new = self.app.get(reverse('new'))
form = new.forms[0]
form['description'] = 'fake description'
......@@ -50,12 +50,17 @@ class MeetingPoll(WebTest):
count=1,
status_code=200)
form = edition.forms[0]
form['choice_set-0-choice_0'] = '06/06/2013 17:00'
form['choice_set-0-choice'] = '30/06/13 17:00'
form['choice_set-0-details'] = 'fake detail'
votepage = form.submit().follow()
# Anne reaches the voting page
self.assertContains(votepage,
'Posted by',
count=1,
status_code=200)
form = votepage.forms[0]
form['2013-06-06 17:00:00-voice'] = 1
form['2013-06-06 17:00:00-comment'] = "jaw-dropping comment"
form['2013-06-30 17:00:00-voice'] = 1
form['2013-06-30 17:00:00-comment'] = "jaw-dropping comment"
votepageagain = form.submit()
self.assertContains(
votepageagain, 'jaw-dropping comment', count=1, status_code=200)
......
......@@ -35,6 +35,8 @@ ACCOUNT_ACTIVATION_DAYS = 7 # Activation window
if django.VERSION >= (1, 6):
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
DATETIME_INPUT_FORMATS = ('%d/%m/%y %H:%M',)
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
......
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