Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5_fork
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
Hide 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):
id
=
field
.
generate_subfield_key
(
name
,
validation
=
1
,
key
=
key
)
if
name
==
"timezone"
:
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
)
def
validate
(
self
,
field
,
key
,
REQUEST
):
...
...
@@ -787,20 +792,22 @@ class DateTimeValidator(Validator):
self
.
raise_error
(
'not_datetime'
,
field
)
if
field
.
get_value
(
'ampm_time_style'
):
ampm
=
self
.
validate_sub_field
(
field
,
key
,
'ampm'
,
REQUEST
)
if
field
.
get_value
(
'allow_empty_time'
):
if
ampm
==
''
:
ampm
=
'am'
hour
=
int
(
hour
)
# handling not am or pm
# handling hour > 12
if
((
ampm
!=
'am'
)
and
(
ampm
!=
'pm'
))
or
(
hour
>
12
):
self
.
raise_error
(
'not_datetime'
,
field
)
if
(
ampm
==
'pm'
)
and
(
hour
==
0
):
self
.
raise_error
(
'not_datetime'
,
field
)
elif
ampm
==
'pm'
and
hour
<
12
:
hour
+=
12
try
:
ampm
=
self
.
validate_sub_field
(
field
,
key
,
'ampm'
,
REQUEST
)
if
field
.
get_value
(
'allow_empty_time'
):
if
ampm
==
''
:
ampm
=
'am'
hour
=
int
(
hour
)
# handling not am or pm
# handling hour > 12
if
((
ampm
!=
'am'
)
and
(
ampm
!=
'pm'
))
or
(
hour
>
12
):
self
.
raise_error
(
'not_datetime'
,
field
)
if
(
ampm
==
'pm'
)
and
(
hour
==
0
):
self
.
raise_error
(
'not_datetime'
,
field
)
elif
ampm
==
'pm'
and
hour
<
12
:
hour
+=
12
except
ValidationError
:
self
.
raise_error
(
'not_datetime'
,
field
)
# handle possible timezone input
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