summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-04-26 08:59:25 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-04-26 08:59:25 (GMT)
commitc121011edc88c19f7d22e6ce4d90a00c447e2087 (patch)
tree5bb26fbf636f09796ab37934f298ec1cc6bf3b5f
parent511ce809af9b6ef96b3693250f3e8692ca6867e1 (diff)
downloadcollective.dms.batchimport-c121011edc88c19f7d22e6ce4d90a00c447e2087.zip
collective.dms.batchimport-c121011edc88c19f7d22e6ce4d90a00c447e2087.tar.gz
collective.dms.batchimport-c121011edc88c19f7d22e6ce4d90a00c447e2087.tar.bz2
add support for presetting recipient groups (#22009)
-rw-r--r--src/collective/dms/batchimport/fileimporter.py7
-rw-r--r--src/collective/dms/batchimport/utils.py11
2 files changed, 16 insertions, 2 deletions
diff --git a/src/collective/dms/batchimport/fileimporter.py b/src/collective/dms/batchimport/fileimporter.py
index 31d3b96..558f75d 100644
--- a/src/collective/dms/batchimport/fileimporter.py
+++ b/src/collective/dms/batchimport/fileimporter.py
@@ -29,6 +29,7 @@ class IImportFileFormSchema(form.Schema):
location = schema.Text(required=False)
owner = schema.Text(required=False)
treating_groups = schema.Text(required=False) # new, comme separated identifiers
+ recipient_groups = schema.Text(required=False) # new, comme separated identifiers
keywords = schema.Text(required=False) # comma separated identifiers
# legacy
@@ -79,13 +80,17 @@ class ImportFileForm(form.SchemaForm):
else:
treating_groups = set([x.strip() for x in (data['treating_groups'] or '').split(',')])
+ recipient_groups = set([x.strip() for x in (data['recipient_groups'] or '').split(',')])
+
folder = self.get_folder(data['location'])
keywords = set([x.strip() for x in (data['keywords'] or '').split(',')])
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, treating_groups=treating_groups,
+ filename, data['file'], owner,
+ treating_groups=treating_groups,
+ recipient_groups=recipient_groups,
metadata={
'title': data.get('title'),
'keywords': keywords,
diff --git a/src/collective/dms/batchimport/utils.py b/src/collective/dms/batchimport/utils.py
index cc2cc35..e3a9a1c 100644
--- a/src/collective/dms/batchimport/utils.py
+++ b/src/collective/dms/batchimport/utils.py
@@ -21,7 +21,8 @@ log = logging.getLogger('collective.dms.batchimport')
def createDocument(context, folder, portal_type, document_id, filename,
- file_object, owner=None, treating_groups=None, metadata=None):
+ file_object, owner=None, treating_groups=None, recipient_groups=None,
+ metadata=None):
if owner is None:
owner = api.user.get_current().id
@@ -52,6 +53,14 @@ def createDocument(context, folder, portal_type, document_id, filename,
IDmsDocument['treating_groups'])
canwrite_dm.set([])
canwrite_dm.set(list(treating_groups))
+
+ if recipient_groups:
+ canread_dm = LocalRolesToPrincipalsDataManager(document,
+ IDmsDocument['recipient_groups'])
+ canread_dm.set([])
+ canread_dm.set(list(recipient_groups))
+
+ if treating_groups or recipient_groups:
document.reindexObjectSecurity()
version = createContentInContainer(document, 'dmsmainfile',