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
Alexander Emmerich
erp5
Commits
5491300c
Commit
5491300c
authored
Mar 15, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: make attachment_list of notification API correctly use bytes
parent
c9f29365
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
20 deletions
+28
-20
bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransactionModule_aggregateFrenchAccountingTransactionFile.py
...sactionModule_aggregateFrenchAccountingTransactionFile.py
+10
-3
bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.Url.py
...cumentTemplateItem/portal_components/document.erp5.Url.py
+3
-3
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createMailMessageAsString.py
.../portal_skins/erp5_base/Base_createMailMessageAsString.py
+4
-4
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testNotificationTool.py
...eItem/portal_components/test.erp5.testNotificationTool.py
+5
-4
bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.py
...l_skins/erp5_deferred_style_core/Base_renderSimpleView.py
+1
-1
bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_report.py
...Item/portal_skins/erp5_deferred_style_core/Base_report.py
+1
-1
product/ERP5/Document/Alarm.py
product/ERP5/Document/Alarm.py
+1
-1
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.NotificationTool.py
...plateItem/portal_components/tool.erp5.NotificationTool.py
+3
-3
No files found.
bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransactionModule_aggregateFrenchAccountingTransactionFile.py
View file @
5491300c
# coding: utf-8
# coding: utf-8
import
unicodedata
import
unicodedata
from
six.moves
import
cStringIO
as
StringIO
import
six
from
io
import
BytesIO
import
zipfile
import
zipfile
from
Products.ERP5Type.Message
import
translateString
from
Products.ERP5Type.Message
import
translateString
...
@@ -22,7 +23,7 @@ if test_compta_demat_compatibility:
...
@@ -22,7 +23,7 @@ if test_compta_demat_compatibility:
'NFKD'
,
fec_file
.
replace
(
u"€"
,
"EUR"
)
'NFKD'
,
fec_file
.
replace
(
u"€"
,
"EUR"
)
).
encode
(
'ascii'
,
'ignore'
)
).
encode
(
'ascii'
,
'ignore'
)
zipbuffer
=
String
IO
()
zipbuffer
=
Bytes
IO
()
zipfilename
=
at_date
.
strftime
(
'FEC-%Y%m%d.zip'
)
zipfilename
=
at_date
.
strftime
(
'FEC-%Y%m%d.zip'
)
zipfileobj
=
zipfile
.
ZipFile
(
zipbuffer
,
'w'
,
compression
=
zipfile
.
ZIP_DEFLATED
)
zipfileobj
=
zipfile
.
ZipFile
(
zipbuffer
,
'w'
,
compression
=
zipfile
.
ZIP_DEFLATED
)
filename
=
'FEC.xml'
filename
=
'FEC.xml'
...
@@ -42,9 +43,15 @@ attachment_list = (
...
@@ -42,9 +43,15 @@ attachment_list = (
'content'
:
zipbuffer
.
getvalue
(),
'content'
:
zipbuffer
.
getvalue
(),
'name'
:
zipfilename
,
},
)
'name'
:
zipfilename
,
},
)
subject
=
translateString
(
'French Accounting Transaction File'
)
if
six
.
PY2
:
subject
=
unicode
(
subject
)
else
:
subject
=
str
(
subject
)
portal
.
ERP5Site_notifyReportComplete
(
portal
.
ERP5Site_notifyReportComplete
(
user_name
=
user_name
,
user_name
=
user_name
,
subject
=
unicode
(
translateString
(
'French Accounting Transaction File'
))
,
subject
=
subject
,
message
=
''
,
message
=
''
,
attachment_list
=
attachment_list
)
attachment_list
=
attachment_list
)
...
...
bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.Url.py
View file @
5491300c
...
@@ -121,9 +121,9 @@ class Url(Coordinate, UrlMixin):
...
@@ -121,9 +121,9 @@ class Url(Coordinate, UrlMixin):
This method was previously named 'SendMail' and is used to send email
This method was previously named 'SendMail' and is used to send email
* attachment_list is a list of dictionnaries with those keys:
* attachment_list is a list of dictionnaries with those keys:
- name : name of the attachment,
- name
(str)
: name of the attachment,
- content: data of the attachment
- content
(bytes)
: data of the attachment
- mime_type: mime-type corresponding to the attachment
- mime_type
(str)
: mime-type corresponding to the attachment
* extra_headers is a dictionnary of custom headers to add to the email.
* extra_headers is a dictionnary of custom headers to add to the email.
"X-" prefix is automatically added to those headers.
"X-" prefix is automatically added to those headers.
"""
"""
...
...
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createMailMessageAsString.py
View file @
5491300c
...
@@ -6,10 +6,10 @@
...
@@ -6,10 +6,10 @@
* body: body of the message as UTF-8 encoded string
* body: body of the message as UTF-8 encoded string
* content_type: mime type of this message, can be text/html for
* content_type: mime type of this message, can be text/html for
HTML message or anything else for text/plain message.
HTML message or anything else for text/plain message.
* attachment_list: a list of attach
e
ment mapping in format:
* attachment_list: a list of attachment mapping in format:
- mime_type
: mime type of thsi attache
ment
- mime_type
(str): mime type of thsi attach
ment
- content
: file content of the attachement, as a string
- content
(bytes): file content of the attachment
- name
: displayed name of this attachements
- name
(str): displayed name of this attachment
* embedded_file_list: a list of ERP5 File to use as attachments.
* embedded_file_list: a list of ERP5 File to use as attachments.
* extra_header_dict: additional email headers
* extra_header_dict: additional email headers
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testNotificationTool.py
View file @
5491300c
...
@@ -54,6 +54,7 @@ def decode_email(file_):
...
@@ -54,6 +54,7 @@ def decode_email(file_):
for
key
,
value
in
msg
.
items
():
for
key
,
value
in
msg
.
items
():
decoded_value_list
=
decode_header
(
value
)
decoded_value_list
=
decode_header
(
value
)
unicode_value
=
make_header
(
decoded_value_list
)
unicode_value
=
make_header
(
decoded_value_list
)
# TODO PY3
new_value
=
unicode_value
.
__unicode__
().
encode
(
'utf-8'
)
new_value
=
unicode_value
.
__unicode__
().
encode
(
'utf-8'
)
theMail
[
'headers'
][
key
.
lower
()]
=
new_value
theMail
[
'headers'
][
key
.
lower
()]
=
new_value
# Filter mail addresses
# Filter mail addresses
...
@@ -302,12 +303,12 @@ class TestNotificationTool(ERP5TypeTestCase):
...
@@ -302,12 +303,12 @@ class TestNotificationTool(ERP5TypeTestCase):
attachment_list
=
[
attachment_list
=
[
{
{
'name'
:
'Attachment 1'
,
'name'
:
'Attachment 1'
,
'content'
:
'Text 1'
,
'content'
:
b
'Text 1'
,
'mime_type'
:
'text/plain'
,
'mime_type'
:
'text/plain'
,
},
},
{
{
'name'
:
'Attachment 2'
,
'name'
:
'Attachment 2'
,
'content'
:
'Text 2'
,
'content'
:
b
'Text 2'
,
'mime_type'
:
'application/octet-stream'
,
'mime_type'
:
'application/octet-stream'
,
},
},
])
])
...
@@ -322,8 +323,8 @@ class TestNotificationTool(ERP5TypeTestCase):
...
@@ -322,8 +323,8 @@ class TestNotificationTool(ERP5TypeTestCase):
mail_dict
=
decode_email
(
messageText
)
mail_dict
=
decode_email
(
messageText
)
self
.
assertEqual
(
mail_dict
[
'headers'
][
'subject'
],
'Subject'
)
self
.
assertEqual
(
mail_dict
[
'headers'
][
'subject'
],
'Subject'
)
self
.
assertEqual
(
mail_dict
[
'body'
],
'Message'
)
self
.
assertEqual
(
mail_dict
[
'body'
],
'Message'
)
self
.
assertSameSet
([(
'Attachment 1'
,
'text/plain'
,
'Text 1'
),
self
.
assertSameSet
([(
'Attachment 1'
,
'text/plain'
,
b
'Text 1'
),
(
'Attachment 2'
,
'application/octet-stream'
,
'Text 2'
)],
(
'Attachment 2'
,
'application/octet-stream'
,
b
'Text 2'
)],
mail_dict
[
'attachment_list'
])
mail_dict
[
'attachment_list'
])
def
test_07_AttachmentMessage
(
self
):
def
test_07_AttachmentMessage
(
self
):
...
...
bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.py
View file @
5491300c
...
@@ -30,7 +30,7 @@ with portal.Localizer.translationContext(localizer_language):
...
@@ -30,7 +30,7 @@ with portal.Localizer.translationContext(localizer_language):
attachment_name
=
attachment_name
[:
-
1
]
attachment_name
=
attachment_name
[:
-
1
]
attachment_list
=
(
attachment_list
=
(
{
'mime_type'
:
(
request
.
RESPONSE
.
getHeader
(
'content-type'
)
or
'application/octet-stream;'
).
split
(
';'
)[
0
],
{
'mime_type'
:
(
request
.
RESPONSE
.
getHeader
(
'content-type'
)
or
'application/octet-stream;'
).
split
(
';'
)[
0
],
'content'
:
'%s'
%
report_data
,
'content'
:
bytes
(
report_data
)
,
'name'
:
attachment_name
},)
'name'
:
attachment_name
},)
getattr
(
portal
,
notify_report_complete_script_id
)(
getattr
(
portal
,
notify_report_complete_script_id
)(
...
...
bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_report.py
View file @
5491300c
...
@@ -49,7 +49,7 @@ with portal.Localizer.translationContext(localizer_language):
...
@@ -49,7 +49,7 @@ with portal.Localizer.translationContext(localizer_language):
attachment_list
=
(
attachment_list
=
(
{
'mime_type'
:
(
request
.
RESPONSE
.
getHeader
(
'content-type'
)
or
'application/octet-stream;'
).
split
(
';'
)[
0
],
{
'mime_type'
:
(
request
.
RESPONSE
.
getHeader
(
'content-type'
)
or
'application/octet-stream;'
).
split
(
';'
)[
0
],
'content'
:
'%s'
%
report_data
,
'content'
:
bytes
(
report_data
)
,
'name'
:
attachment_name
},)
'name'
:
attachment_name
},)
getattr
(
portal
,
notify_report_complete_script_id
)(
getattr
(
portal
,
notify_report_complete_script_id
)(
...
...
product/ERP5/Document/Alarm.py
View file @
5491300c
...
@@ -355,7 +355,7 @@ class Alarm(XMLObject, PeriodicityMixin):
...
@@ -355,7 +355,7 @@ class Alarm(XMLObject, PeriodicityMixin):
for
x
in
result_list
]
for
x
in
result_list
]
rendered_alarm_result
=
'
\
n
'
.
join
(
rendered_alarm_result_list
)
rendered_alarm_result
=
'
\
n
'
.
join
(
rendered_alarm_result_list
)
attachment_list
.
append
({
'name'
:
'alarm_result.txt'
,
attachment_list
.
append
({
'name'
:
'alarm_result.txt'
,
'content'
:
rendered_alarm_result
,
'content'
:
rendered_alarm_result
.
encode
()
,
'mime_type'
:
'text/plain'
})
'mime_type'
:
'text/plain'
})
notification_tool
.
sendMessage
(
recipient
=
candidate_list
,
notification_tool
.
sendMessage
(
recipient
=
candidate_list
,
...
...
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.NotificationTool.py
View file @
5491300c
...
@@ -109,9 +109,9 @@ def buildEmailMessage(from_url, to_url, msg=None,
...
@@ -109,9 +109,9 @@ def buildEmailMessage(from_url, to_url, msg=None,
sent by Zope MailHost.
sent by Zope MailHost.
* attachment_list is a list of dictionaries with those keys:
* attachment_list is a list of dictionaries with those keys:
- name
: name of the attachment,
- name
(str): name of the attachment
- content: data of the attachment
- content
(bytes)
: data of the attachment
- mime_type: mime-type corresponding to the attachment
- mime_type
(str)
: mime-type corresponding to the attachment
* extra_headers is a dictionary of custom headers to add to the email.
* extra_headers is a dictionary of custom headers to add to the email.
"X-" prefix is automatically added to those headers.
"X-" prefix is automatically added to those headers.
* additional_headers is similar to extra_headers, but no prefix is added.
* additional_headers is similar to extra_headers, but no prefix is added.
...
...
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