summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-04-26 08:54:53 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-04-26 08:55:32 (GMT)
commit511ce809af9b6ef96b3693250f3e8692ca6867e1 (patch)
treea670fcf31a6fdc092219cd0affd77e6904917767
parent10c1e517908eefe9b5a5ee02217bd6c3faa9e25d (diff)
downloadcollective.dms.batchimport-511ce809af9b6ef96b3693250f3e8692ca6867e1.zip
collective.dms.batchimport-511ce809af9b6ef96b3693250f3e8692ca6867e1.tar.gz
collective.dms.batchimport-511ce809af9b6ef96b3693250f3e8692ca6867e1.tar.bz2
add support to define more than one treating group
-rw-r--r--src/collective/dms/batchimport/fileimporter.py13
-rw-r--r--src/collective/dms/batchimport/utils.py6
2 files changed, 13 insertions, 6 deletions
diff --git a/src/collective/dms/batchimport/fileimporter.py b/src/collective/dms/batchimport/fileimporter.py
index 2201f01..31d3b96 100644
--- a/src/collective/dms/batchimport/fileimporter.py
+++ b/src/collective/dms/batchimport/fileimporter.py
@@ -28,9 +28,12 @@ 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)
+ treating_groups = schema.Text(required=False) # new, comme separated identifiers
keywords = schema.Text(required=False) # comma separated identifiers
+ # legacy
+ treating_group = schema.Text(required=False)
+
class ImportFileForm(form.SchemaForm):
schema = IImportFileFormSchema
@@ -71,14 +74,18 @@ class ImportFileForm(form.SchemaForm):
portal_type = data['portal_type']
filename = data['file'].filename
owner = data['owner']
- treating_group = data['treating_group']
+ if data['treating_group']: # legacy
+ treating_groups = set([data['treating_group']])
+ else:
+ treating_groups = set([x.strip() for x in (data['treating_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_group=treating_group,
+ filename, data['file'], owner, treating_groups=treating_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 6e06c5f..cc2cc35 100644
--- a/src/collective/dms/batchimport/utils.py
+++ b/src/collective/dms/batchimport/utils.py
@@ -21,7 +21,7 @@ log = logging.getLogger('collective.dms.batchimport')
def createDocument(context, folder, portal_type, document_id, filename,
- file_object, owner=None, treating_group=None, metadata=None):
+ file_object, owner=None, treating_groups=None, metadata=None):
if owner is None:
owner = api.user.get_current().id
@@ -47,11 +47,11 @@ def createDocument(context, folder, portal_type, document_id, filename,
if IDeadline and IDeadline.providedBy(document):
document.deadline = deadlineDefaultValue(None)
- if treating_group:
+ if treating_groups:
canwrite_dm = LocalRolesToPrincipalsDataManager(document,
IDmsDocument['treating_groups'])
canwrite_dm.set([])
- canwrite_dm.set([treating_group])
+ canwrite_dm.set(list(treating_groups))
document.reindexObjectSecurity()
version = createContentInContainer(document, 'dmsmainfile',