allow multiple responsibles on a task (#4846)
This commit is contained in:
parent
113a2527e5
commit
7b9fe6c4ab
|
@ -1,3 +1,5 @@
|
|||
from copy import deepcopy
|
||||
|
||||
from z3c.form import button
|
||||
from z3c.form.field import Fields
|
||||
from z3c.form.interfaces import HIDDEN_MODE
|
||||
|
@ -70,13 +72,18 @@ class AttributeTask(DefaultAddForm):
|
|||
if errors:
|
||||
self.status = self.formErrorsMessage
|
||||
return
|
||||
obj = self.createAndAdd(data)
|
||||
obj = None
|
||||
for responsible in data['responsible']:
|
||||
_data = deepcopy(data)
|
||||
_data['responsible'] = [responsible]
|
||||
obj = self.createAndAdd(_data)
|
||||
if obj is not None:
|
||||
# mark only as finished if we get the new object
|
||||
self._finishedAdd = True
|
||||
IStatusMessage(self.request).addStatusMessage(DMF(u"Item created"), "info")
|
||||
# set Editor role to task responsible on the first non Task object in acquisition
|
||||
nontask = find_nontask(parent_task)
|
||||
nontask.manage_addLocalRoles(obj.responsible[0], ['Editor',])
|
||||
for responsible in data['responsible']:
|
||||
nontask.manage_addLocalRoles(responsible, ['Editor',])
|
||||
nontask.reindexObjectSecurity()
|
||||
self.immediate_view = "%s/content_status_modify?workflow_action=%s" % (container_url, workflow_action)
|
||||
|
|
|
@ -1,14 +1,30 @@
|
|||
from zope.interface import implements
|
||||
from zope import schema
|
||||
|
||||
from plone.autoform import directives as form
|
||||
from plone.dexterity.content import Container
|
||||
from plone import api
|
||||
|
||||
from collective.z3cform.rolefield.field import LocalRolesToPrincipals
|
||||
from collective.dms.basecontent.widget import AjaxChosenMultiFieldWidget
|
||||
|
||||
from collective.task import _
|
||||
from collective.task.interfaces import IBaseTask, IDeadline
|
||||
|
||||
|
||||
class ITask(IBaseTask, IDeadline):
|
||||
"""Schema for task"""
|
||||
pass
|
||||
|
||||
responsible = LocalRolesToPrincipals(
|
||||
title=_(u"Addressees"),
|
||||
roles_to_assign=('Editor',),
|
||||
value_type=schema.Choice(
|
||||
vocabulary="dms.principals"
|
||||
),
|
||||
min_length=1,
|
||||
required=True,
|
||||
)
|
||||
form.widget(responsible=AjaxChosenMultiFieldWidget)
|
||||
|
||||
|
||||
class Task(Container):
|
||||
|
|
|
@ -20,12 +20,12 @@ def get_document(obj):
|
|||
|
||||
@indexer(IBaseTask)
|
||||
def enquirer(obj, **kw):
|
||||
return obj.enquirer and obj.enquirer[0] or ''
|
||||
return obj.enquirer and obj.enquirer or []
|
||||
|
||||
|
||||
@indexer(IBaseTask)
|
||||
def responsible(obj, **kw):
|
||||
return obj.responsible and obj.responsible[0] or ''
|
||||
return obj.responsible and obj.responsible or []
|
||||
|
||||
|
||||
@indexer(IBaseTask)
|
||||
|
|
|
@ -25,8 +25,8 @@ log = getLogger(__name__)
|
|||
|
||||
def grant_local_role_to_responsible(context, role, target):
|
||||
"""Grant local role to responsible on target"""
|
||||
responsible = context.responsible[0]
|
||||
target.manage_addLocalRoles(responsible, [role])
|
||||
for responsible in context.responsible:
|
||||
target.manage_addLocalRoles(responsible, [role])
|
||||
target.reindexObject()
|
||||
|
||||
|
||||
|
|
Reference in New Issue