Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUP-29258_linked_opinion_editors_permissions #208

Open
wants to merge 1 commit into
base: liege-urban2.5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/SUP-29258.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Give opinion editor roles on road decree's bound licence
[daggelpop]
25 changes: 24 additions & 1 deletion src/Products/urban/workflows/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
from plone import api
from plone.memoize.request import cache

from Products.Archetypes.config import REFERENCE_CATALOG
from Products.CMFCore.WorkflowCore import WorkflowException
from Products.CMFCore.utils import getToolByName

from Products.urban.content.licence.RoadDecree import RoadDecree
from Products.urban.interfaces import ICODT_IntegratedLicence
from Products.urban.interfaces import ICODT_UniqueLicence
from Products.urban.interfaces import IEnvironmentBase
from Products.urban.interfaces import IIntegratedLicence
from Products.urban.interfaces import IUniqueLicence

from zope.component import getAdapters
from zope.interface import implements


Expand Down Expand Up @@ -56,6 +60,22 @@ def get_allowed_groups(self, licence):
else:
return 'urban_only'

def get_linked_opinion_editors(self):
linked_opinion_editors = []
if self.context.portal_type in RoadDecree.schema['bound_licence'].allowed_types:
reference_catalog = getToolByName(self.context, REFERENCE_CATALOG)
back_refs = reference_catalog.getBackReferences(self.context, 'bound_licence')
if back_refs:
back_obj = [ref.getSourceObject() for ref in back_refs][0]
back_obj_local_role_adapters = [
adapter for name, adapter in getAdapters((back_obj,), ILocalRoleProvider)
if hasattr(adapter, 'get_opinion_editors')
]
for back_obj_local_role_adapter in back_obj_local_role_adapters:
f = back_obj_local_role_adapter.get_opinion_editors()
linked_opinion_editors.extend(f)
return linked_opinion_editors

def get_opinion_editors(self):
"""
Return groups who have external opinion to give on the licence.
Expand All @@ -80,7 +100,10 @@ def get_opinion_editors(self):
if group not in exceptions:
opinion_editors.append(group)

return opinion_editors
back_ref_opinion_editors = self.get_linked_opinion_editors()
opinion_editors.extend(back_ref_opinion_editors)

return list(set(opinion_editors))

def get_editors(self):
""" """
Expand Down