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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
b57ecc2a
Commit
b57ecc2a
authored
Apr 12, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
substitution
parent
e74ad5ea
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
173 additions
and
14 deletions
+173
-14
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationMessage_viewEditor.xml
...portal_skins/erp5_base/NotificationMessage_viewEditor.xml
+8
-6
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationMessage_viewEditor/my_text_content_substitution_mapping_ignore_missing.xml
...r/my_text_content_substitution_mapping_ignore_missing.xml
+84
-0
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testNotificationMessageModule.py
...tal_components/test.erp5.testNotificationMessageModule.py
+11
-2
bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_setTextContentFromNotificationMessage.py
...s/erp5_crm/Event_setTextContentFromNotificationMessage.py
+6
-3
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
...plateItem/portal_components/document.erp5.TextDocument.py
+5
-3
product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/TextDocument/text_content_substitution_mapping_ignore_missing_property.xml
..._content_substitution_mapping_ignore_missing_property.xml
+59
-0
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationMessage_viewEditor.xml
View file @
b57ecc2a
...
...
@@ -59,8 +59,8 @@
<key>
<string>
group_list
</string>
</key>
<value>
<list>
<string>
left
(Page Properties)
</string>
<string>
right
(Publication)
</string>
<string>
left
</string>
<string>
right
</string>
<string>
center
</string>
<string>
bottom
</string>
</list>
...
...
@@ -85,18 +85,20 @@
</value>
</item>
<item>
<key>
<string>
left
(Page Properties)
</string>
</key>
<key>
<string>
left
</string>
</key>
<value>
<list>
<string>
my_content_type
</string>
<string>
my_text_content_substitution_mapping_method_id
</string>
</list>
</value>
</item>
<item>
<key>
<string>
right
(Publication)
</string>
</key>
<key>
<string>
right
</string>
</key>
<value>
<list/>
<list>
<string>
my_text_content_substitution_mapping_method_id
</string>
<string>
my_text_content_substitution_mapping_ignore_missing
</string>
</list>
</value>
</item>
</dictionary>
...
...
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/NotificationMessage_viewEditor/my_text_content_substitution_mapping_ignore_missing.xml
0 → 100644
View file @
b57ecc2a
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ProxyField"
module=
"Products.ERP5Form.ProxyField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
delegated_list
</string>
</key>
<value>
<list>
<string>
title
</string>
</list>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
my_text_content_substitution_mapping_ignore_missing
</string>
</value>
</item>
<item>
<key>
<string>
message_values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
external_validator_failed
</string>
</key>
<value>
<string>
The input failed the external validator.
</string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
overrides
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
tales
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_checkbox
</string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string>
Base_viewFieldLibrary
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Ignore Missing Substitution Variables
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testNotificationMessageModule.py
View file @
b57ecc2a
...
...
@@ -152,8 +152,9 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
self
.
assertEqual
(
'substitution text: b'
,
text
.
rstrip
())
def
test_safe_substitution_content
(
self
):
"""Tests that 'safe' substitution is performed, unless safe_substitute is
explicitly passed to False.
"""Tests that 'safe' substitution is performed, unless the notification
message is configured text_content_substitution_mapping_ignore_missing set
to false, or safe_substitute is passed as False.
"""
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
...
...
@@ -175,6 +176,14 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'html'
,
safe_substitute
=
False
)
self
.
assertRaises
(
KeyError
,
doc
.
asSubjectText
,
safe_substitute
=
False
)
doc
.
setTextContentSubstitutionMappingIgnoreMissing
(
False
)
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'txt'
)
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'html'
)
self
.
assertRaises
(
KeyError
,
doc
.
asSubjectText
)
mime
,
text
=
doc
.
convert
(
'txt'
,
safe_substitute
=
True
)
self
.
assertEqual
(
'substitution text: ${b}'
,
text
.
rstrip
())
self
.
assertEqual
(
'${b}'
,
doc
.
asSubjectText
(
safe_substitute
=
True
))
def
test_substitution_lazy_dict
(
self
):
"""Substitution script just needs to return an object implementing
__getitem__ protocol.
...
...
bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_setTextContentFromNotificationMessage.py
View file @
b57ecc2a
...
...
@@ -20,12 +20,15 @@ if notification_message is not None:
target_format
=
"txt"
if
context
.
getContentType
()
==
'text/html'
:
target_format
=
"html"
_
,
text_content
=
notification_message
.
convert
(
target_format
,
substitution_method_parameter_dict
=
substitution_method_parameter_dict
)
_
,
text_content
=
notification_message
.
convert
(
target_format
,
substitution_method_parameter_dict
=
substitution_method_parameter_dict
,
safe_substitute
=
notification_message
.
isTextContentSubstitutionMappingIgnoreMissing
())
context
.
setTextContent
(
text_content
)
context
.
setAggregateSet
(
context
.
getAggregateList
()
+
notification_message
.
getProperty
(
'aggregate_list'
,
[]))
if
not
context
.
hasTitle
():
context
.
setTitle
(
notification_message
.
asSubjectText
(
substitution_method_parameter_dict
=
substitution_method_parameter_dict
))
substitution_method_parameter_dict
=
substitution_method_parameter_dict
,
safe_substitute
=
notification_message
.
isTextContentSubstitutionMappingIgnoreMissing
()))
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
View file @
b57ecc2a
...
...
@@ -75,7 +75,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
,
PropertySheet
.
Reference
)
def
_substituteTextContent
(
self
,
text
,
safe_substitute
=
True
,
**
kw
):
def
_substituteTextContent
(
self
,
text
,
safe_substitute
=
_MARKER
,
**
kw
):
# If a method for string substitutions of the text content, perform it.
# Decode everything into unicode before the substitutions, in order to
# avoid encoding errors.
...
...
@@ -104,6 +104,8 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
return
v
unicode_mapping
=
UnicodeMapping
()
if
safe_substitute
is
_MARKER
:
safe_substitute
=
self
.
isTextContentSubstitutionMappingIgnoreMissing
()
if
safe_substitute
:
text
=
Template
(
text
).
safe_substitute
(
unicode_mapping
)
else
:
...
...
@@ -116,7 +118,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
return
text
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asSubjectText'
)
def
asSubjectText
(
self
,
substitution_method_parameter_dict
=
None
,
safe_substitute
=
True
,
**
kw
):
def
asSubjectText
(
self
,
substitution_method_parameter_dict
=
None
,
safe_substitute
=
_MARKER
,
**
kw
):
"""
Converts the subject of the document to a textual representation.
"""
...
...
@@ -127,7 +129,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
**
substitution_method_parameter_dict
)
def
_convert
(
self
,
format
,
substitution_method_parameter_dict
=
None
,
# pylint: disable=redefined-builtin
safe_substitute
=
True
,
charset
=
None
,
text_content
=
None
,
substitute
=
True
,
**
kw
):
safe_substitute
=
_MARKER
,
charset
=
None
,
text_content
=
None
,
substitute
=
True
,
**
kw
):
"""
Convert text using portal_transforms or oood
"""
...
...
product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/TextDocument/text_content_substitution_mapping_ignore_missing_property.xml
0 → 100644
View file @
b57ecc2a
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Standard Property"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_local_properties
</string>
</key>
<value>
<tuple>
<dictionary>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
mode
</string>
</value>
</item>
<item>
<key>
<string>
type
</string>
</key>
<value>
<string>
string
</string>
</value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
elementary_type/boolean
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string>
Ignore missing entries from substitution mapping.\n
\n
When ignoring, missing entries will be kept as is, otherwise substitution will be an error.
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
text_content_substitution_mapping_ignore_missing_property
</string>
</value>
</item>
<item>
<key>
<string>
mode
</string>
</key>
<value>
<string>
w
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Standard Property
</string>
</value>
</item>
<item>
<key>
<string>
property_default
</string>
</key>
<value>
<string>
python: True
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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