Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
etch
nuages
Commits
87e082ad
Commit
87e082ad
authored
Jun 22, 2015
by
Christophe Siraut
Browse files
meetingpoll/forms: work with lastest django-datetime-widget (9.3) which
brings backward incompatible changes.
parent
2aa64cde
Changes
3
Hide whitespace changes
Inline
Side-by-side
meetingpoll/forms.py
View file @
87e082ad
...
...
@@ -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
)
)
...
...
meetingpoll/test_functional.py
View file @
87e082ad
...
...
@@ -25,8 +25,8 @@ class MeetingPoll(WebTest):
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_poll_creation
(
self
):
#
Gerald
wants to create a poll
#
H
e forget to fill the form title
#
Anne
wants to create a poll
#
Sh
e 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
'
]
=
'0
6
/06/
20
13 17:00'
form
[
'choice_set-0-choice'
]
=
'
3
0/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-0
6
17:00:00-voice'
]
=
1
form
[
'2013-06-0
6
17:00:00-comment'
]
=
"jaw-dropping comment"
form
[
'2013-06-
3
0 17:00:00-voice'
]
=
1
form
[
'2013-06-
3
0 17:00:00-comment'
]
=
"jaw-dropping comment"
votepageagain
=
form
.
submit
()
self
.
assertContains
(
votepageagain
,
'jaw-dropping comment'
,
count
=
1
,
status_code
=
200
)
...
...
nuages/settings.py
View file @
87e082ad
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment