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
Thomas Gambier
erp5
Commits
0aeea3c4
Commit
0aeea3c4
authored
Jan 06, 2021
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Plain Diff
Validation message translation
See merge request
nexedi/erp5!1001
parents
1b11dd03
4e12f94c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+1
-1
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/field_render.zpt
...mplateItem/portal_skins/erp5_xhtml_style/field_render.zpt
+1
-2
product/Formulator/Errors.py
product/Formulator/Errors.py
+13
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
0aeea3c4
...
@@ -1042,7 +1042,7 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
...
@@ -1042,7 +1042,7 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
try
:
try
:
response_dict
[
field
.
id
]
=
renderField
(
traversed_document
,
field
,
form
,
key_prefix
=
key_prefix
,
selection_params
=
selection_params
,
request_field
=
not
use_relation_form_page_template
)
response_dict
[
field
.
id
]
=
renderField
(
traversed_document
,
field
,
form
,
key_prefix
=
key_prefix
,
selection_params
=
selection_params
,
request_field
=
not
use_relation_form_page_template
)
if
field_errors
.
has_key
(
field
.
id
):
if
field_errors
.
has_key
(
field
.
id
):
response_dict
[
field
.
id
][
"error_text"
]
=
field_errors
[
field
.
id
].
error_text
response_dict
[
field
.
id
][
"error_text"
]
=
field_errors
[
field
.
id
].
getMessage
(
Base_translateString
)
except
AttributeError
as
error
:
except
AttributeError
as
error
:
# Do not crash if field configuration is wrong.
# Do not crash if field configuration is wrong.
log
(
"Field {} rendering failed because of {!s}"
.
format
(
field
.
id
,
error
),
level
=
800
)
log
(
"Field {} rendering failed because of {!s}"
.
format
(
field
.
id
,
error
),
level
=
800
)
...
...
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/field_render.zpt
View file @
0aeea3c4
...
@@ -30,8 +30,7 @@
...
@@ -30,8 +30,7 @@
<div class="input" tal:content="structure python: html_tuple[1]" />
<div class="input" tal:content="structure python: html_tuple[1]" />
<span tal:condition="field_has_error"
<span tal:condition="field_has_error"
class="error"
class="error"
tal:content="python: field_errors[field_id].error_text"
tal:content="python: field_errors[field_id].getMessage(here.Base_translateString)" />
i18n:translate="" i18n:domain="ui" />
<p class="clear" tal:condition="not:is_web_mode"></p>
<p class="clear" tal:condition="not:is_web_mode"></p>
</tal:block>
</tal:block>
</div>
</div>
...
...
product/Formulator/Errors.py
View file @
0aeea3c4
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
# from Products.Formulator.Errors import ValidationError, FormValidationError
# from Products.Formulator.Errors import ValidationError, FormValidationError
from
Products.PythonScripts.Utility
import
allow_class
from
Products.PythonScripts.Utility
import
allow_class
from
AccessControl
import
ClassSecurityInfo
class
FormValidationError
(
Exception
):
class
FormValidationError
(
Exception
):
...
@@ -17,6 +18,8 @@ allow_class(FormValidationError)
...
@@ -17,6 +18,8 @@ allow_class(FormValidationError)
class
ValidationError
(
Exception
):
class
ValidationError
(
Exception
):
security
=
ClassSecurityInfo
()
def
__init__
(
self
,
error_key
,
field
,
error_text
=
None
):
def
__init__
(
self
,
error_key
,
field
,
error_text
=
None
):
Exception
.
__init__
(
self
,
error_key
)
Exception
.
__init__
(
self
,
error_key
)
self
.
error_key
=
error_key
self
.
error_key
=
error_key
...
@@ -24,8 +27,18 @@ class ValidationError(Exception):
...
@@ -24,8 +27,18 @@ class ValidationError(Exception):
self
.
field
=
field
self
.
field
=
field
if
error_text
is
not
None
:
if
error_text
is
not
None
:
self
.
error_text
=
error_text
self
.
error_text
=
error_text
self
.
is_message_to_translate
=
False
else
:
else
:
self
.
error_text
=
field
.
get_error_message
(
error_key
)
self
.
error_text
=
field
.
get_error_message
(
error_key
)
self
.
is_message_to_translate
=
True
security
.
declarePublic
(
'getMessage'
)
def
getMessage
(
self
,
translation_service
=
None
):
if
not
self
.
is_message_to_translate
:
return
self
.
error_text
if
translation_service
is
None
:
return
self
.
error_text
return
translation_service
(
self
.
error_text
)
allow_class
(
ValidationError
)
allow_class
(
ValidationError
)
...
...
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