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
Nikola Balog
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
()
portal
=
context
.
getPortalObject
()
domain
=
context
.
getDefaultEventPathDestinationValue
()
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
:
if
domain
is
None
:
message
=
'Recipients must be defined'
return
redirect
(
'Recipients must be defined'
)
else
:
event_path
=
context
.
getDefaultEventPathValue
(
portal_type
=
"Event Path"
)
if
event_path
.
getEventPortalType
()
is
None
:
method_kw
=
{
'event_path'
:
event_path
.
getRelativeUrl
(),
return
redirect
(
'Event Type must be defined'
)
'keep_draft'
:
keep_draft
}
portal
.
portal_catalog
.
activate
(
activity
=
'SQLQueue'
).
searchAndActivate
(
if
event_path
.
getSourceValue
()
is
None
:
"Entity_createEventFromDefaultEventPath"
,
return
redirect
(
'Sender must be defined'
)
selection_domain
=
{
domain
.
getParentId
():
(
'portal_domains'
,
domain
.
getRelativeUrl
())},
method_kw
=
method_kw
)
if
event_path
.
getResourceValue
()
is
None
:
message
=
'Events are being created in background'
return
redirect
(
'Notification Message must be defined'
)
return
context
.
Base_redirect
(
keep_items
=
{
'portal_status_message'
:
context
.
Base_translateString
(
message
)})
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 @@
...
@@ -27,6 +27,7 @@
##############################################################################
##############################################################################
import
unittest
import
unittest
import
urlparse
import
os
import
os
import
textwrap
import
textwrap
from
unittest
import
expectedFailure
from
unittest
import
expectedFailure
...
@@ -509,14 +510,12 @@ class TestCRM(BaseTestCRM):
...
@@ -509,14 +510,12 @@ class TestCRM(BaseTestCRM):
portal
=
self
.
portal
portal
=
self
.
portal
notification_message_reference
=
'campaign-Event.Path'
notification_message_reference
=
'campaign-Event.Path'
service
=
portal
.
service_module
.
newContent
(
portal_type
=
'Service'
)
service
=
portal
.
service_module
.
newContent
(
portal_type
=
'Service'
)
resource
=
portal
.
notification_message_module
.
newContent
(
notification_message
=
portal
.
notification_message_module
.
newContent
(
reference
=
notification_message_reference
,
content_type
=
"text/html"
,
content_type
=
"text/html"
,
portal_type
=
"Notification Message"
,
portal_type
=
"Notification Message"
,
specialise_value
=
service
,
specialise_value
=
service
,
text_content_substitution_mapping_method_id
=
mapping_method_id
,
text_content_substitution_mapping_method_id
=
mapping_method_id
,
text_content
=
"Hello ${destination_title}"
)
text_content
=
"Hello ${destination_title}"
)
resource
.
validate
()
sender
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
sender
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
reference
=
'sender'
,
first_name
=
'Sender'
)
reference
=
'sender'
,
first_name
=
'Sender'
)
first_user
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
first_user
=
portal
.
person_module
.
newContent
(
portal_type
=
"Person"
,
...
@@ -537,13 +536,54 @@ class TestCRM(BaseTestCRM):
...
@@ -537,13 +536,54 @@ class TestCRM(BaseTestCRM):
organisation_domain
.
setCriterionPropertyList
([
'portal_type'
])
organisation_domain
.
setCriterionPropertyList
([
'portal_type'
])
organisation_domain
.
setCriterion
(
'portal_type'
,
identity
=
[
'Organisation'
])
organisation_domain
.
setCriterion
(
'portal_type'
,
identity
=
[
'Organisation'
])
campaign
=
self
.
portal
.
campaign_module
.
newContent
(
portal_type
=
"Campaign"
,
campaign
=
self
.
portal
.
campaign_module
.
newContent
(
default_event_path_event_portal_type
=
"Mail Message"
,
portal_type
=
"Campaign"
,
default_event_path_destination
=
"portal_domains/%s"
%
person_domain
.
getRelativeUrl
(),
default_event_path_event_portal_type
=
"Mail Message"
,)
default_event_path_source
=
sender
.
getRelativeUrl
(),
default_event_path_resource
=
resource
.
getRelativeUrl
())
# 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
()
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
()
self
.
tic
()
event_list
=
[
event
for
event
in
campaign
.
getFollowUpRelatedValueList
()
event_list
=
[
event
for
event
in
campaign
.
getFollowUpRelatedValueList
()
if
event
.
getPortalType
()
!=
'Mail Message'
]
if
event
.
getPortalType
()
!=
'Mail Message'
]
...
@@ -562,7 +602,7 @@ class TestCRM(BaseTestCRM):
...
@@ -562,7 +602,7 @@ class TestCRM(BaseTestCRM):
default_event_path_event_portal_type
=
"Visit"
,
default_event_path_event_portal_type
=
"Visit"
,
default_event_path_destination
=
'portal_domains/%s'
%
organisation_domain
.
getRelativeUrl
(),
default_event_path_destination
=
'portal_domains/%s'
%
organisation_domain
.
getRelativeUrl
(),
default_event_path_source
=
sender
.
getRelativeUrl
(),
default_event_path_source
=
sender
.
getRelativeUrl
(),
default_event_path_resource
=
resourc
e
.
getRelativeUrl
())
default_event_path_resource
=
notification_messag
e
.
getRelativeUrl
())
self
.
tic
()
self
.
tic
()
campaign
.
Ticket_createEventFromDefaultEventPath
()
campaign
.
Ticket_createEventFromDefaultEventPath
()
self
.
tic
()
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