Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
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):
...
@@ -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,20 +792,22 @@ class DateTimeValidator(Validator):
...
@@ -787,20 +792,22 @@ 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'
):
ampm
=
self
.
validate_sub_field
(
field
,
key
,
'ampm'
,
REQUEST
)
try
:
if
field
.
get_value
(
'allow_empty_time'
):
ampm
=
self
.
validate_sub_field
(
field
,
key
,
'ampm'
,
REQUEST
)
if
ampm
==
''
:
if
field
.
get_value
(
'allow_empty_time'
):
ampm
=
'am'
if
ampm
==
''
:
hour
=
int
(
hour
)
ampm
=
'am'
# handling not am or pm
hour
=
int
(
hour
)
# handling hour > 12
# handling not am or pm
if
((
ampm
!=
'am'
)
and
(
ampm
!=
'pm'
))
or
(
hour
>
12
):
# handling hour > 12
self
.
raise_error
(
'not_datetime'
,
field
)
if
((
ampm
!=
'am'
)
and
(
ampm
!=
'pm'
))
or
(
hour
>
12
):
if
(
ampm
==
'pm'
)
and
(
hour
==
0
):
self
.
raise_error
(
'not_datetime'
,
field
)
self
.
raise_error
(
'not_datetime'
,
field
)
if
(
ampm
==
'pm'
)
and
(
hour
==
0
):
elif
ampm
==
'pm'
and
hour
<
12
:
self
.
raise_error
(
'not_datetime'
,
field
)
hour
+=
12
elif
ampm
==
'pm'
and
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