Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
595fee10
Commit
595fee10
authored
Jun 17, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: WIP support event's attachment
parent
a1a10bee
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Ticket_createProjectEvent.py
..._skins/slapos_crm_monitoring/Ticket_createProjectEvent.py
+29
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Ticket_createProjectEvent.xml
...skins/slapos_crm_monitoring/Ticket_createProjectEvent.xml
+1
-1
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Ticket_createProjectEvent.py
View file @
595fee10
"""Generic script to add event
"""Generic script to add event
It creates new Event for any context which become follow_up of created Event.
It creates new Event for any context which become follow_up of created Event.
"""
"""
from
erp5.component.tool.NotificationTool
import
buildEmailMessage
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
ticket
=
context
ticket
=
context
REQUEST
=
context
.
REQUEST
# Max ~3Mb
if
int
(
REQUEST
.
getHeader
(
'Content-Length'
,
0
))
>
3145728
:
raise
ValueError
(
'Huge attachment is not supported'
)
# Create a mail message to allow attachment in the event
attachment_list
=
[]
if
attachment
:
# Build dict wrapper for NotificationTool
mime_type
=
attachment
.
headers
.
get
(
'Content-Type'
,
''
)
content
=
attachment
.
read
()
name
=
getattr
(
attachment
,
'filename'
,
None
)
attachment
=
dict
(
mime_type
=
mime_type
,
content
=
content
,
name
=
name
)
attachment_list
.
append
(
attachment
)
email
=
buildEmailMessage
(
from_url
=
None
,
to_url
=
None
,
msg
=
text_content
,
subject
=
title
,
attachment_list
=
attachment_list
)
if
direction
==
'outgoing'
:
if
direction
==
'outgoing'
:
source_relative_url
=
source
or
ticket
.
getSource
()
source_relative_url
=
source
or
ticket
.
getSource
()
...
@@ -21,6 +46,9 @@ elif direction == 'incoming':
...
@@ -21,6 +46,9 @@ elif direction == 'incoming':
else
:
else
:
raise
NotImplementedError
(
'The specified direction is not handled: %r'
%
(
direction
,))
raise
NotImplementedError
(
'The specified direction is not handled: %r'
%
(
direction
,))
if
(
notification_message
is
not
None
)
and
(
attachment
is
not
None
):
raise
ValueError
(
'Can not add attachment to a notification message'
)
event_kw
=
{
event_kw
=
{
'portal_type'
:
portal_type
,
'portal_type'
:
portal_type
,
'resource'
:
resource
,
'resource'
:
resource
,
...
@@ -33,7 +61,7 @@ event_kw = {
...
@@ -33,7 +61,7 @@ event_kw = {
'start_date'
:
DateTime
(),
'start_date'
:
DateTime
(),
'follow_up_value'
:
ticket
,
'follow_up_value'
:
ticket
,
'language'
:
language
,
'language'
:
language
,
'
text_content'
:
text_content
,
'
data'
:
email
.
as_string
()
,
'content_type'
:
content_type
,
'content_type'
:
content_type
,
}
}
# Create event
# Create event
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Ticket_createProjectEvent.xml
View file @
595fee10
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
title, direction, portal_type, resource, text_content, content_type, notification_message=None, substitution_method_parameter_dict=None, keep_draft=False, source=None, destination=None, language=None, comment=None, **kw
</string>
</value>
<value>
<string>
title, direction, portal_type, resource, text_content, content_type,
attachment=None,
notification_message=None, substitution_method_parameter_dict=None, keep_draft=False, source=None, destination=None, language=None, comment=None, **kw
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
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