summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2014-02-24 13:31:00 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2014-02-24 13:31:00 (GMT)
commit1c831ec4c4b5a816602d371a171d1af818b012b9 (patch)
treebe746f0755b8df37a32462032cafff5f46ae59e2
parent46612b45e52c6d165c2e8cc4973a681b986a41b5 (diff)
downloadcollective.dms.batchimport-1c831ec4c4b5a816602d371a171d1af818b012b9.zip
collective.dms.batchimport-1c831ec4c4b5a816602d371a171d1af818b012b9.tar.gz
collective.dms.batchimport-1c831ec4c4b5a816602d371a171d1af818b012b9.tar.bz2
add possibility to set treating group
-rw-r--r--src/collective/dms/batchimport/fileimporter.py5
-rw-r--r--src/collective/dms/batchimport/utils.py13
2 files changed, 16 insertions, 2 deletions
diff --git a/src/collective/dms/batchimport/fileimporter.py b/src/collective/dms/batchimport/fileimporter.py
index 645877a..6745807 100644
--- a/src/collective/dms/batchimport/fileimporter.py
+++ b/src/collective/dms/batchimport/fileimporter.py
@@ -28,6 +28,7 @@ class IImportFileFormSchema(form.Schema):
portal_type = schema.Text(required=False)
location = schema.Text(required=False)
owner = schema.Text(required=False)
+ treating_group = schema.Text(required=False)
class ImportFileForm(form.SchemaForm):
@@ -69,9 +70,11 @@ class ImportFileForm(form.SchemaForm):
portal_type = data['portal_type']
filename = data['file'].filename
owner = data['owner']
+ treating_group = data['treating_group']
folder = self.get_folder(data['location'])
document_id = self.convertTitleToId(data.get('title') or os.path.splitext(filename)[0])
utils.createDocument(self, folder, portal_type, document_id,
- filename, data['file'], owner, {'title': data.get('title')})
+ filename, data['file'], owner, treating_group=treating_group,
+ metadata={'title': data.get('title')})
diff --git a/src/collective/dms/batchimport/utils.py b/src/collective/dms/batchimport/utils.py
index 3887733..f8624a8 100644
--- a/src/collective/dms/batchimport/utils.py
+++ b/src/collective/dms/batchimport/utils.py
@@ -5,6 +5,10 @@ from plone import api
from plone.dexterity.utils import createContentInContainer
from collective.dms.mailcontent.dmsmail import internalReferenceIncomingMailDefaultValue, receptionDateDefaultValue
+from collective.dms.basecontent.dmsdocument import IDmsDocument
+
+from collective.z3cform.rolefield.field import LocalRolesToPrincipalsDataManager
+
try:
from pfwbged.basecontent.behaviors import IDeadline, deadlineDefaultValue
@@ -17,7 +21,7 @@ log = logging.getLogger('collective.dms.batchimport')
def createDocument(context, folder, portal_type, document_id, filename,
- file_object, owner=None, metadata=None):
+ file_object, owner=None, treating_group=None, metadata=None):
if owner is None:
owner = api.user.get_current().id
@@ -43,6 +47,13 @@ def createDocument(context, folder, portal_type, document_id, filename,
if IDeadline and IDeadline.providedBy(document):
document.deadline = deadlineDefaultValue(None)
+ if treating_group:
+ canwrite_dm = LocalRolesToPrincipalsDataManager(document,
+ IDmsDocument['treating_groups'])
+ canwrite_dm.set([])
+ canwrite_dm.set([treating_group])
+ document.reindexObjectSecurity()
+
version = createContentInContainer(document, 'dmsmainfile',
title=_('Scanned Mail'),
file=file_object)