add support for presetting recipient groups (#22009)
This commit is contained in:
parent
511ce809af
commit
c121011edc
|
@ -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,
|
||||
|
|
|
@ -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',
|
||||
|
|
Reference in New Issue