def __init__(self, context, request): """self:zope.app.pagetemplate.simpleviewclass.SimpleViewClass -> templates/workspace-index.pt context:bungeni.core.content.Section """ LD = IAnnotations(request)["layer_data"] assert interfaces.IWorkspaceSectionLayer.providedBy(request) assert LD.get("workspaces") is not None super(WorkspaceSectionView, self).__init__(context, request) cls_name = self.__class__.__name__ # NOTE: Zope morphs this class's name to "SimpleViewClass from ..." log.debug("%s.__init__ %s context=%s url=%s" % ( cls_name, self, self.context, request.getURL())) # transfer layer data items, for the view/template self.user_id = LD.user_id self.user_group_ids = LD.user_group_ids self.government_id = LD.government_id # may be None self.ministries = LD.ministries # may be None if self.ministries: # then, ONLY if an ancestor container is actually a Ministry, # this must be a MinisterWorkspace if misc.get_parent_with_interface(self, model_interfaces.IMinistry): interface.alsoProvides(self, interfaces.IMinisterWorkspace) # roles are function of the context, so always recalculate roles = get_roles(self.context) for role_id in roles: iface = self.role_interface_mapping.get(role_id) if iface is not None: interface.alsoProvides(self, iface) log.debug("%s.__init__ %s" % (cls_name, debug.interfaces(self)))
def __init__(self, context, request): """self:zope.app.pagetemplate.simpleviewclass.SimpleViewClass -> templates/workspace-index.pt context:bungeni.core.content.Section """ LD = IAnnotations(request)["layer_data"] assert interfaces.IWorkspaceSectionLayer.providedBy(request) assert LD.get("workspaces") is not None super(WorkspaceSectionView, self).__init__(context, request) cls_name = self.__class__.__name__ # NOTE: Zope morphs this class's name to "SimpleViewClass from ..." log.debug("%s.__init__ %s context=%s url=%s" % (cls_name, self, self.context, request.getURL())) # transfer layer data items, for the view/template self.user_id = LD.user_id self.user_group_ids = LD.user_group_ids self.government_id = LD.government_id # may be None self.ministries = LD.ministries # may be None if self.ministries: # then, ONLY if an ancestor container is actually a Ministry, # this must be a MinisterWorkspace if misc.get_parent_with_interface(self, model_interfaces.IMinistry): interface.alsoProvides(self, interfaces.IMinisterWorkspace) # roles are function of the context, so always recalculate roles = common.get_context_roles(self.context) for role_id in roles: iface = self.role_interface_mapping.get(role_id) if iface is not None: interface.alsoProvides(self, iface) log.debug("%s.__init__ %s" % (cls_name, debug.interfaces(self)))
def update(self): # should only ever be called for contexts with these interfaces assert (IWorkspaceContainer.providedBy(self.context) or IWorkspaceSectionContext.providedBy(self.context)) self.sections = getMenu("workspace_context_navigation", self.context, self.request) # get a translated copy of original workspace object workspace = translate_obj( misc.get_parent_with_interface(self, IWorkspaceContainer)) self.workspace_title = workspace.full_name
def update(self): # should only ever be called for contexts with these interfaces assert IWorkspaceContainer.providedBy(self.context) or IWorkspaceSectionContext.providedBy(self.context) self.sections = getMenu("workspace_context_navigation", self.context, self.request) # Append a trailing slash to each workspace viewlet navigation entry so # that the right context is always maintained when using this navigation. for section in self.sections: section["url"] = url.set_url_context(section["url"]) # get a translated copy of original workspace object workspace = translate_obj(misc.get_parent_with_interface(self, IWorkspaceContainer)) self.workspace_title = workspace.full_name
def update(self): # should only ever be called for contexts with these interfaces assert (IWorkspaceContainer.providedBy(self.context) or IWorkspaceSectionContext.providedBy(self.context)) self.sections = getMenu("workspace_context_navigation", self.context, self.request) # Append a trailing slash to each workspace viewlet navigation entry so # that the right context is always maintained when using this navigation. for section in self.sections: section["url"] = url.set_url_context(section["url"]) # get a translated copy of original workspace object workspace = translate_obj( misc.get_parent_with_interface(self, IWorkspaceContainer)) self.workspace_title = workspace.full_name