def render_tree(self): context_path = '/'.join(self.context.getPhysicalPath()) query_filter = { 'object_provides': ( IRepositoryFolder.__identifier__, IDossierMarker.__identifier__, ), 'blocked_local_roles': True, } dossier_container_brains = api.content.find( context=self.context, **query_filter) if dossier_container_brains: title = escape_html(translate( _( u'label_blocked_local_roles', default=u'Protected Objects', ), context=getRequest(), )) title_element = u''.join((u'<h1>', title, u'</h1>', )) tree = Treeify( dossier_container_brains, context_path, node_updater, ) # XXX - Preserving the reference number tree order. # Sorting here was easier than figuring out the treeifying. iterable_children = sorted( tree(self.context).get('children', ()), key=lambda child: child.get('title', ''), ) rendered_tree = self._build_html_tree(iterable_children) garnished_tree = ''.join(( title_element, rendered_tree, )) return garnished_tree title = escape_html(translate( _( u'label_no_blocked_local_roles', default=u'No protected objects were found within this scope.', ), context=getRequest(), )) title_element = u''.join((u'<h1>', title, u'</h1>', )) return title_element
def translations(self): return json.dumps({ 'label_search': self.plone_translate('label_search'), 'label_inherit_local_roles': self.plone_translate('label_inherit_local_roles'), 'help_inherit_local_roles': self.translate( _(u'help_inherit_local_roles', default=u'By default, permissions from the container of this ' u'item are inherited. If you disable this, only the ' u'explicitly defined sharing permissions will be valid.')), 'image_link_icon': self.plone_translate('image_link_icon'), 'image_confirm_icon': self.plone_translate('image_confirm_icon'), 'principal_search_placeholder': self.translate( _(u'principal_search_placeholder', default=u'Search for Users and Groups')), 'label_name': self.plone_translate('label_name'), 'label_acquired': self.translate( _(u'label_acquired_permission', default=u'Acquired permission')), 'label_local': self.translate( _(u'label_local_permission', default=u'Local permission')), 'label_save': self.translate(PMF(u'Save')), 'label_cancel': self.translate(PMF(u'Cancel')), 'label_automatic_permission': self.translate( _(u'label_automatic_permission', default=u'Automatic permission')), 'label_local_permission': self.translate( _(u'label_local_permission', default=u'Local permission')), 'label_save_failed': self.translate( _(u'message_save_failed', default=u'Local roles save failed.')), 'message_title_error': self.translate( base_mf('message_title_error', default=u"Error")), })
def saved(self): """Redirects to absolute_url and adds statusmessage. """ message = _(u'label_roles_successfully_changed', default=u'Local roles successfully changed') api.portal.show_message( message=message, request=self.request, type='info') return self.request.RESPONSE.redirect(self.context.absolute_url())
def saved(self): """Redirects to absolute_url and adds statusmessage. """ message = _(u'label_roles_successfully_changed', default=u'Local roles successfully changed') api.portal.show_message(message=message, request=self.request, type='info') return self.request.RESPONSE.redirect(self.context.absolute_url())
def translations(self): return json.dumps({ 'label_search': self.plone_translate('label_search'), 'label_inherit_local_roles': self.plone_translate('label_inherit_local_roles'), 'help_inherit_local_roles': self.translate( _(u'help_inherit_local_roles', default=u'By default, permissions from the container of this ' u'item are inherited. If you disable this, only the ' u'explicitly defined sharing permissions will be valid.')), 'image_link_icon': self.plone_translate('image_link_icon'), 'image_confirm_icon': self.plone_translate('image_confirm_icon'), 'principal_search_placeholder': self.translate( _(u'principal_search_placeholder', default=u'Search for Users and Groups')), 'label_name': self.plone_translate('label_name'), 'label_acquired': self.translate( _(u'label_acquired_permission', default=u'Acquired permission')), 'label_local': self.translate( _(u'label_local_permission', default=u'Local permission')), 'label_save': self.translate(PMF(u'Save')), 'label_cancel': self.translate(PMF(u'Cancel')), 'label_automatic_permission': self.translate( _(u'label_automatic_permission', default=u'Automatic permission')), 'label_local_permission': self.translate( _(u'label_local_permission', default=u'Local permission')), 'label_save_failed': self.translate( _(u'message_save_failed', default=u'Local roles save failed.')), 'message_title_error': self.translate(base_mf('message_title_error', default=u"Error")), })
from opengever.sharing.events import LocalRolesAcquisitionActivated from opengever.sharing.events import LocalRolesAcquisitionBlocked from opengever.sharing.events import LocalRolesModified from opengever.sharing.interfaces import ISharingConfiguration from plone.app.workflow.browser.sharing import SharingView from plone.app.workflow.interfaces import ISharingPageRole from plone.memoize.instance import memoize from plone.registry.interfaces import IRegistry from zope.component import getUtilitiesFor from zope.component import getUtility from zope.event import notify import re ROLE_MAPPING = ( (IDossier, ( (u'Reader', _('sharing_dossier_reader')), (u'Contributor', _('sharing_dossier_contributor')), (u'Editor', _('sharing_dossier_editor')), (u'Reviewer', _('sharing_dossier_reviewer')), (u'Publisher', _('sharing_dossier_publisher')), )), (IStandard, ( (u'Reader', _('sharing_reader')), (u'Contributor', _('sharing_contributor')), (u'Editor', _('sharing_editor')), (u'Role Manager', _('sharing_role_manager')), )), ) class OpengeverSharingView(SharingView):
def render_tree(self): context_path = '/'.join(self.context.getPhysicalPath()) query_filter = { 'object_provides': ( IRepositoryFolder.__identifier__, IDossierMarker.__identifier__, ), 'blocked_local_roles': True, } dossier_container_brains = api.content.find(context=self.context, **query_filter) if dossier_container_brains: title = escape_html( translate( _( u'label_blocked_local_roles', default=u'Protected Objects', ), context=getRequest(), )) title_element = u''.join(( u'<h1>', title, u'</h1>', )) tree = Treeify( dossier_container_brains, context_path, self.node_updater, ) # XXX - Preserving the reference number tree order. # Sorting here was easier than figuring out the treeifying. iterable_children = sorted( tree(self.context).get('children', ()), key=lambda child: child.get('title', ''), ) rendered_tree = self._build_html_tree(iterable_children) garnished_tree = ''.join(( title_element, rendered_tree, )) return garnished_tree title = escape_html( translate( _( u'label_no_blocked_local_roles', default= u'No protected objects were found within this scope.', ), context=getRequest(), )) title_element = u''.join(( u'<h1>', title, u'</h1>', )) return title_element
from plone.app.workflow.browser.sharing import SharingView from plone.app.workflow.interfaces import ISharingPageRole from plone.memoize.instance import memoize from plone.registry.interfaces import IRegistry from Products.CMFCore.utils import getToolByName from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from urllib import urlencode from zope.component import getUtilitiesFor from zope.component import getUtility from zope.event import notify import re ROLE_MAPPING = ( (IDossier, ( (u'Reader', _('sharing_dossier_reader')), (u'Contributor', _('sharing_dossier_contributor')), (u'Editor', _('sharing_dossier_editor')), (u'Reviewer', _('sharing_dossier_reviewer')), (u'Publisher', _('sharing_dossier_publisher')), (u'DossierManager', _('sharing_dossier_manager')), )), (IStandard, ( (u'Reader', _('sharing_reader')), (u'Contributor', _('sharing_contributor')), (u'Editor', _('sharing_editor')), (u'Role Manager', _('sharing_role_manager')), )), )