Set conditions to create a board decision from a note for board #38884
- User is a member of group Gestion-secretariat-general - There is no existing board decision related to that note for board
This commit is contained in:
parent
d24bb396d1
commit
fb769655c1
|
@ -1,6 +1,42 @@
|
|||
from five import grok
|
||||
from plone import api
|
||||
from pfwbged.basecontent.types import INoteForBoard
|
||||
from plone import api
|
||||
from zc.relation.interfaces import ICatalog
|
||||
from zope.component import getUtility
|
||||
from zope.intid.interfaces import IIntIds
|
||||
|
||||
|
||||
class CanCreateBoardDecision(grok.View):
|
||||
"""Create a board decision from a note for board"""
|
||||
|
||||
grok.name('can_create_board_decision')
|
||||
grok.context(INoteForBoard)
|
||||
grok.require("zope2.View")
|
||||
|
||||
def in_gestion_sg(self):
|
||||
return any([group for group in api.group.get_groups(user=api.user.get_current()) if
|
||||
group.id == 'Gestion-secretariat-general'])
|
||||
|
||||
def board_decision_created(self):
|
||||
"""Return true if a board decision has been created for this note for board"""
|
||||
intids = getUtility(IIntIds)
|
||||
catalog = getUtility(ICatalog)
|
||||
try:
|
||||
note_intid = intids.getId(self.context)
|
||||
except KeyError:
|
||||
return False
|
||||
else:
|
||||
return any(catalog.findRelations({'to_id': note_intid,
|
||||
'from_attribute': 'related_docs'}))
|
||||
|
||||
def render(self):
|
||||
if not self.in_gestion_sg():
|
||||
return False
|
||||
|
||||
if self.board_decision_created():
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class CreateBoardDecision(grok.View):
|
||||
|
|
Reference in New Issue