summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/collective/dms/batchimport/fileimporter.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/collective/dms/batchimport/fileimporter.py b/src/collective/dms/batchimport/fileimporter.py
index 558f75d..3af748b 100644
--- a/src/collective/dms/batchimport/fileimporter.py
+++ b/src/collective/dms/batchimport/fileimporter.py
@@ -1,7 +1,13 @@
+# -*- coding: utf8 -*-
+
import logging
import os
import os.path
+from email.mime.base import MIMEBase
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+
from zope import schema
from zope.component import queryUtility
@@ -32,6 +38,8 @@ class IImportFileFormSchema(form.Schema):
recipient_groups = schema.Text(required=False) # new, comme separated identifiers
keywords = schema.Text(required=False) # comma separated identifiers
+ notification_recipients = schema.Text(required=False) # comma separated emails
+
# legacy
treating_group = schema.Text(required=False)
@@ -95,3 +103,19 @@ class ImportFileForm(form.SchemaForm):
'title': data.get('title'),
'keywords': keywords,
})
+
+ if data.get('notification_recipients'):
+ document_location = self.request.response.headers['location']
+ subject = 'Nouveau document, %s' % data.get('title')
+ message = 'Ouvrir dans la GED :\n %s\n' % document_location
+ recipients = data.get('notification_recipients').split(',')
+ self.send_message(subject, message, recipients)
+
+ def send_message(self, subject, message, recipients):
+ msg = MIMEMultipart()
+ msg['Subject'] = subject
+ msg['To'] = ', '.join(recipients)
+ msg['From'] = api.portal.get().getProperty('email_from_address') or 'admin@localhost'
+
+ msg.attach(MIMEText(message, _charset='utf-8'))
+ self.context.MailHost.send(msg.as_string())