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
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Lu Xu
erp5
Commits
5e7ad3b7
Commit
5e7ad3b7
authored
Feb 08, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5: check constraints in notificiation tool's sendMessage
parent
caa86d0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
product/ERP5/Tool/NotificationTool.py
product/ERP5/Tool/NotificationTool.py
+14
-6
product/ERP5/tests/testNotificationTool.py
product/ERP5/tests/testNotificationTool.py
+3
-5
No files found.
product/ERP5/Tool/NotificationTool.py
View file @
5e7ad3b7
...
...
@@ -233,6 +233,7 @@ class NotificationTool(BaseTool):
attachment_list
=
None
,
attachment_document_list
=
None
,
notifier_list
=
None
,
priority_level
=
None
,
store_as_event
=
False
,
check_consistency
=
True
,
message_text_format
=
'text/plain'
,
event_keyword_argument_dict
=
None
,
portal_type_list
=
None
):
...
...
@@ -271,6 +272,13 @@ class NotificationTool(BaseTool):
store_as_event -- whenever CRM is available, store
notifications as events
check_consistency -- Check that the created events match their constraints.
If any of the event have an unsatisified constraint, a
ValueError is raised.
Note that if `store_as_event` is true, some draft
events are created anyway, so caller may want to
abort transaction.
event_keyword_argument_dict -- additional keyword arguments which is used for
constructor of event document.
...
...
@@ -317,12 +325,6 @@ class NotificationTool(BaseTool):
raise
IndexError
,
"Can't find person document which reference is '%s'"
%
person
else
:
person
=
person_value
email_value
=
person
.
getDefaultEmailValue
()
if
email_value
is
None
:
# For backward compatibility. I recommend to use ValueError.(yusei)
raise
AttributeError
,
"Can't find default email address of %s"
%
person
.
getRelativeUrl
()
if
not
email_value
.
asText
():
raise
AttributeError
,
"Default email address of %s is empty"
%
person
.
getRelativeUrl
()
to_person_list
.
append
(
person
)
# prepare low-level arguments if needed.
...
...
@@ -367,6 +369,12 @@ class NotificationTool(BaseTool):
event
.
setAggregateValueList
(
attachment_document_list
)
event_list
.
append
(
event
)
if
check_consistency
:
for
event
in
event_list
:
constraint_message_list
=
event
.
checkConsistency
()
if
constraint_message_list
:
raise
ValueError
(
constraint_message_list
)
for
event
in
event_list
:
if
event
.
isTempObject
()
or
(
not
portal
.
portal_workflow
.
isTransitionPossible
(
event
,
'start'
)):
event
.
send
(
**
low_level_kw
)
...
...
product/ERP5/tests/testNotificationTool.py
View file @
5e7ad3b7
...
...
@@ -369,11 +369,9 @@ class TestNotificationTool(ERP5TypeTestCase):
"""
Check that notification fails when the destination hasn't a email adress
"""
self
.
assertRaises
(
AttributeError
,
self
.
portal
.
portal_notifications
.
sendMessage
,
recipient
=
'userWithoutEmail'
,
subject
=
'Subject'
,
message
=
'Message'
)
with
self
.
assertRaises
(
ValueError
):
self
.
portal
.
portal_notifications
.
sendMessage
(
recipient
=
'userWithoutEmail'
,
subject
=
'Subject'
,
message
=
'Message'
)
def
test_08_PersonWithoutEmail
(
self
):
sequence_list
=
SequenceList
()
...
...
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