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
Matevz Golob
erp5
Commits
d4b63a3d
Commit
d4b63a3d
authored
Dec 29, 2017
by
Tomáš Peterka
Committed by
Tomáš Peterka
Jan 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hal_json] Pass correct request to form fields for value resolution
parent
777c5e6c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+15
-8
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
d4b63a3d
...
@@ -309,9 +309,11 @@ url_template_dict = {
...
@@ -309,9 +309,11 @@ url_template_dict = {
default_document_uri_template
=
url_template_dict
[
"jio_get_template"
]
default_document_uri_template
=
url_template_dict
[
"jio_get_template"
]
Base_translateString
=
context
.
getPortalObject
().
Base_translateString
Base_translateString
=
context
.
getPortalObject
().
Base_translateString
def
getRealRelativeUrl
(
document
):
def
getRealRelativeUrl
(
document
):
return
'/'
.
join
(
portal
.
portal_url
.
getRelativeContentPath
(
document
))
return
'/'
.
join
(
portal
.
portal_url
.
getRelativeContentPath
(
document
))
def
getFormRelativeUrl
(
form
):
def
getFormRelativeUrl
(
form
):
return
portal
.
portal_catalog
(
return
portal
.
portal_catalog
(
portal_type
=
"ERP5 Form"
,
portal_type
=
"ERP5 Form"
,
...
@@ -321,12 +323,17 @@ def getFormRelativeUrl(form):
...
@@ -321,12 +323,17 @@ def getFormRelativeUrl(form):
select_dict
=
{
'relative_url'
:
None
}
select_dict
=
{
'relative_url'
:
None
}
)[
0
].
relative_url
)[
0
].
relative_url
def
getFieldDefault
(
traversed_document
,
field
,
key
,
value
=
None
):
# REQUEST.get(field.id, field.get_value("default"))
def
getFieldDefault
(
form
,
field
,
key
,
value
=
None
):
result
=
traversed_document
.
Field_getDefaultValue
(
field
,
key
,
value
,
REQUEST
)
"""Get available value for `field` preferably in python-object from REQUEST or from field's default."""
if
getattr
(
result
,
'translate'
,
None
)
is
not
None
:
if
value
is
None
:
result
=
"%s"
%
result
value
=
(
REQUEST
.
form
.
get
(
field
.
id
,
REQUEST
.
form
.
get
(
key
,
None
))
or
return
result
field
.
get_value
(
'default'
,
request
=
REQUEST
,
REQUEST
=
REQUEST
))
if
field
.
has_value
(
"unicode"
)
and
field
.
get_value
(
"unicode"
)
and
isinstance
(
value
,
'unicode'
):
value
=
unicode
(
value
,
self
.
get_form_encoding
())
if
getattr
(
value
,
'translate'
,
None
)
is
not
None
:
return
"%s"
%
value
return
value
def
renderField
(
traversed_document
,
field
,
form
,
value
=
None
,
meta_type
=
None
,
key
=
None
,
key_prefix
=
None
,
selection_params
=
None
):
def
renderField
(
traversed_document
,
field
,
form
,
value
=
None
,
meta_type
=
None
,
key
=
None
,
key_prefix
=
None
,
selection_params
=
None
):
...
@@ -358,7 +365,7 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
...
@@ -358,7 +365,7 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
# fields have default value and can be required (unlike boxes)
# fields have default value and can be required (unlike boxes)
result
.
update
({
result
.
update
({
"required"
:
field
.
get_value
(
"required"
)
if
field
.
has_value
(
"required"
)
else
None
,
"required"
:
field
.
get_value
(
"required"
)
if
field
.
has_value
(
"required"
)
else
None
,
"default"
:
getFieldDefault
(
traversed_document
,
field
,
result
[
"key"
]
,
value
),
"default"
:
getFieldDefault
(
form
,
field
,
key
,
value
),
})
})
if
meta_type
==
"ProxyField"
:
if
meta_type
==
"ProxyField"
:
...
@@ -423,7 +430,7 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
...
@@ -423,7 +430,7 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
"hide_day"
:
field
.
get_value
(
'hide_day'
),
"hide_day"
:
field
.
get_value
(
'hide_day'
),
"hidden_day_is_last_day"
:
field
.
get_value
(
'hidden_day_is_last_day'
),
"hidden_day_is_last_day"
:
field
.
get_value
(
'hidden_day_is_last_day'
),
})
})
date_value
=
getFieldDefault
(
traversed_document
,
field
,
result
[
"key"
]
,
value
)
date_value
=
getFieldDefault
(
form
,
field
,
key
,
value
)
if
not
date_value
and
field
.
get_value
(
'default_now'
):
if
not
date_value
and
field
.
get_value
(
'default_now'
):
date_value
=
DateTime
()
date_value
=
DateTime
()
if
same_type
(
date_value
,
DateTime
()):
if
same_type
(
date_value
,
DateTime
()):
...
...
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