Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ekaterina
erp5
Commits
d71c4187
Commit
d71c4187
authored
Mar 05, 2015
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formulator DateTimeField: add ampm validate
parent
13ea2b27
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
product/Formulator/Validator.py
product/Formulator/Validator.py
+21
-14
No files found.
product/Formulator/Validator.py
View file @
d71c4187
...
@@ -741,6 +741,11 @@ class DateTimeValidator(Validator):
...
@@ -741,6 +741,11 @@ class DateTimeValidator(Validator):
id
=
field
.
generate_subfield_key
(
name
,
validation
=
1
,
key
=
key
)
id
=
field
.
generate_subfield_key
(
name
,
validation
=
1
,
key
=
key
)
if
name
==
"timezone"
:
if
name
==
"timezone"
:
return
REQUEST
.
get
(
id
)
return
REQUEST
.
get
(
id
)
if
name
==
"ampm"
:
ampm
=
REQUEST
.
get
(
id
)
if
ampm
in
(
'am'
,
'pm'
):
return
ampm
raise
ValidationError
(
'not_datetime'
,
field
)
return
IntegerValidatorInstance
.
validate
(
field
,
id
,
REQUEST
)
return
IntegerValidatorInstance
.
validate
(
field
,
id
,
REQUEST
)
def
validate
(
self
,
field
,
key
,
REQUEST
):
def
validate
(
self
,
field
,
key
,
REQUEST
):
...
@@ -787,6 +792,7 @@ class DateTimeValidator(Validator):
...
@@ -787,6 +792,7 @@ class DateTimeValidator(Validator):
self
.
raise_error
(
'not_datetime'
,
field
)
self
.
raise_error
(
'not_datetime'
,
field
)
if
field
.
get_value
(
'ampm_time_style'
):
if
field
.
get_value
(
'ampm_time_style'
):
try
:
ampm
=
self
.
validate_sub_field
(
field
,
key
,
'ampm'
,
REQUEST
)
ampm
=
self
.
validate_sub_field
(
field
,
key
,
'ampm'
,
REQUEST
)
if
field
.
get_value
(
'allow_empty_time'
):
if
field
.
get_value
(
'allow_empty_time'
):
if
ampm
==
''
:
if
ampm
==
''
:
...
@@ -800,7 +806,8 @@ class DateTimeValidator(Validator):
...
@@ -800,7 +806,8 @@ class DateTimeValidator(Validator):
self
.
raise_error
(
'not_datetime'
,
field
)
self
.
raise_error
(
'not_datetime'
,
field
)
elif
ampm
==
'pm'
and
hour
<
12
:
elif
ampm
==
'pm'
and
hour
<
12
:
hour
+=
12
hour
+=
12
except
ValidationError
:
self
.
raise_error
(
'not_datetime'
,
field
)
# handle possible timezone input
# handle possible timezone input
timezone
=
''
timezone
=
''
...
...
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