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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
6749766d
Commit
6749766d
authored
Apr 12, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crm: Add some checks for "Create Events of Communication Plan" action
parent
4accffef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
22 deletions
+81
-22
bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Ticket_createEventFromDefaultEventPath.py
..._skins/erp5_crm/Ticket_createEventFromDefaultEventPath.py
+31
-12
bt5/erp5_crm/TestTemplateItem/portal_components/test.erp5.testCRM.py
...m/TestTemplateItem/portal_components/test.erp5.testCRM.py
+50
-10
No files found.
bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Ticket_createEventFromDefaultEventPath.py
View file @
6749766d
portal
=
context
.
getPortalObject
()
domain
=
context
.
getDefaultEventPathDestinationValue
()
def
redirect
(
message
):
return
context
.
Base_redirect
(
keep_items
=
{
'portal_status_message'
:
context
.
Base_translateString
(
message
)})
event_path
=
context
.
getDefaultEventPathValue
()
if
domain
is
None
:
message
=
'Recipients must be defined'
else
:
event_path
=
context
.
getDefaultEventPathValue
(
portal_type
=
"Event Path"
)
method_kw
=
{
'event_path'
:
event_path
.
getRelativeUrl
(),
'keep_draft'
:
keep_draft
}
portal
.
portal_catalog
.
activate
(
activity
=
'SQLQueue'
).
searchAndActivate
(
"Entity_createEventFromDefaultEventPath"
,
selection_domain
=
{
domain
.
getParentId
():
(
'portal_domains'
,
domain
.
getRelativeUrl
())},
method_kw
=
method_kw
)
message
=
'Events are being created in background'
return
context
.
Base_redirect
(
keep_items
=
{
'portal_status_message'
:
context
.
Base_translateString
(
message
)})
return
redirect
(
'Recipients must be defined'
)
if
event_path
.
getEventPortalType
()
is
None
:
return
redirect
(
'Event Type must be defined'
)
if
event_path
.
getSourceValue
()
is
None
:
return
redirect
(
'Sender must be defined'
)
if
event_path
.
getResourceValue
()
is
None
:
return
redirect
(
'Notification Message must be defined'
)
if
(
not
event_path
.
getResourceReference
())
\
or
portal
.
notification_message_module
.
NotificationTool_getDocumentValue
(
event_path
.
getResourceReference
())
is
None
:
return
redirect
(
'Notification Message must be validated'
)
event_path
=
context
.
getDefaultEventPathValue
(
portal_type
=
"Event Path"
)
method_kw
=
{
'event_path'
:
event_path
.
getRelativeUrl
(),
'keep_draft'
:
keep_draft
,
}
portal
.
portal_catalog
.
activate
(
activity
=
'SQLQueue'
).
searchAndActivate
(
"Entity_createEventFromDefaultEventPath"
,
selection_domain
=
{
domain
.
getParentId
():
(
'portal_domains'
,
domain
.
getRelativeUrl
())},
method_kw
=
method_kw
)
return
redirect
(
'Events are being created in background'
)
bt5/erp5_crm/TestTemplateItem/portal_components/test.erp5.testCRM.py
View file @
6749766d
...
...
@@ -27,6 +27,7 @@
##############################################################################
import
unittest
import
urlparse
import
os
import
textwrap
from
unittest
import
expectedFailure
...
...
@@ -509,14 +510,12 @@ class TestCRM(BaseTestCRM):
portal
=
self
.
portal
notification_message_reference
=
'campaign-Event.Path'
service
=
portal
.
service_module
.
newContent
(
portal_type
=
'Service'
)
resource
=
portal
.
notification_message_module
.
newContent
(
reference
=
notification_message_reference
,
notification_message
=
portal
.
notification_message_module
.
newContent
(
content_type
=
"text/html"
,
portal_type
=
"Notification Message"
,
specialise_value
=
service
,
text_content_substitution_mapping_method_id
=
mapping_method_id
,
text_content
=
"Hello ${destination_title}"
)
resource
.
validate
()
sender
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
reference
=
'sender'
,
first_name
=
'Sender'
)
first_user
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
...
...
@@ -537,13 +536,54 @@ class TestCRM(BaseTestCRM):
organisation_domain
.
setCriterionPropertyList
([
'portal_type'
])
organisation_domain
.
setCriterion
(
'portal_type'
,
identity
=
[
'Organisation'
])
campaign
=
self
.
portal
.
campaign_module
.
newContent
(
portal_type
=
"Campaign"
,
default_event_path_event_portal_type
=
"Mail Message"
,
default_event_path_destination
=
"portal_domains/%s"
%
person_domain
.
getRelativeUrl
(),
default_event_path_source
=
sender
.
getRelativeUrl
(),
default_event_path_resource
=
resource
.
getRelativeUrl
())
campaign
=
self
.
portal
.
campaign_module
.
newContent
(
portal_type
=
"Campaign"
,
default_event_path_event_portal_type
=
"Mail Message"
,)
# This action checks everything is properly defined
ret
=
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
assertEqual
(
urlparse
.
parse_qs
(
urlparse
.
urlparse
(
ret
).
query
)[
'portal_status_message'
],
[
"Recipients must be defined"
])
campaign
.
setDefaultEventPathDestination
(
"portal_domains/%s"
%
person_domain
.
getRelativeUrl
())
campaign
.
setDefaultEventPathEventPortalType
(
None
)
ret
=
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
assertEqual
(
urlparse
.
parse_qs
(
urlparse
.
urlparse
(
ret
).
query
)[
'portal_status_message'
],
[
"Event Type must be defined"
])
campaign
.
setDefaultEventPathEventPortalType
(
'Mail Message'
)
ret
=
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
assertEqual
(
urlparse
.
parse_qs
(
urlparse
.
urlparse
(
ret
).
query
)[
'portal_status_message'
],
[
"Sender must be defined"
])
campaign
.
setDefaultEventPathSource
(
sender
.
getRelativeUrl
())
ret
=
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
assertEqual
(
urlparse
.
parse_qs
(
urlparse
.
urlparse
(
ret
).
query
)[
'portal_status_message'
],
[
"Notification Message must be defined"
])
campaign
.
setDefaultEventPathResource
(
notification_message
.
getRelativeUrl
())
ret
=
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
assertEqual
(
urlparse
.
parse_qs
(
urlparse
.
urlparse
(
ret
).
query
)[
'portal_status_message'
],
[
"Notification Message must be validated"
])
notification_message
.
setReference
(
notification_message_reference
)
ret
=
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
assertEqual
(
urlparse
.
parse_qs
(
urlparse
.
urlparse
(
ret
).
query
)[
'portal_status_message'
],
[
"Notification Message must be validated"
])
notification_message
.
validate
()
self
.
tic
()
campaign
.
Ticket_createEventFromDefaultEventPath
()
ret
=
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
assertEqual
(
urlparse
.
parse_qs
(
urlparse
.
urlparse
(
ret
).
query
)[
'portal_status_message'
],
[
"Events are being created in background"
])
self
.
tic
()
event_list
=
[
event
for
event
in
campaign
.
getFollowUpRelatedValueList
()
if
event
.
getPortalType
()
!=
'Mail Message'
]
...
...
@@ -562,7 +602,7 @@ class TestCRM(BaseTestCRM):
default_event_path_event_portal_type
=
"Visit"
,
default_event_path_destination
=
'portal_domains/%s'
%
organisation_domain
.
getRelativeUrl
(),
default_event_path_source
=
sender
.
getRelativeUrl
(),
default_event_path_resource
=
resourc
e
.
getRelativeUrl
())
default_event_path_resource
=
notification_messag
e
.
getRelativeUrl
())
self
.
tic
()
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
tic
()
...
...
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