def navigation_root(self): """ The root node for the navigation. :result: Nearest node in the :meth:`lineage` that provides :class:`kotti.interfaces.INavigationRoot` or :meth:`root` if no node provides that interface. :rtype: :class:`kotti.resources.Node` """ for o in self.lineage: if INavigationRoot.providedBy(o): return o return self.root
def local_navigation(context, request): def ch(node): return [child for child in node.values() if child.in_navigation and has_permission('view', child, request)] parent = context children = ch(context) if not children and context.__parent__ is not None: parent = context.__parent__ children = ch(parent) if len(children) and parent != get_root() and not \ INavigationRoot.providedBy(parent): return dict(parent=parent, children=children) return dict(parent=None)
def local_navigation(context, request): def ch(node): return [ child for child in node.values() if child.in_navigation and request.has_permission("view", child) ] parent = context children = ch(context) if not children and getattr(context, "__parent__", None) is not None: parent = context.__parent__ children = ch(parent) if children and parent != get_root() and not INavigationRoot.providedBy(parent): return dict(parent=parent, children=children) return dict(parent=None)
def local_navigation(context, request): def ch(node): return [ child for child in node.values() if child.in_navigation and request.has_permission("view", child) ] parent = context children = ch(context) if not children and getattr(context, "__parent__", None) is not None: parent = context.__parent__ children = ch(parent) if children and parent != get_root() and not INavigationRoot.providedBy( parent): return dict(parent=parent, children=children) return dict(parent=None)
def addable(self, context, request): resolver = DottedNameResolver() if hasattr(self, 'dotted_class'): resource_class = resolver.maybe_resolve(self.dotted_class) if resource_class: already_exists_action = DBSession.query(resource_class).\ filter(resource_class.parent_id == context.id).first() if already_exists_action is not None: return False else: return False else: return False if INavigationRoot.providedBy(context) and \ view_permitted(context, request, self.add_view): return True else: return False
def navigation_root(self): for o in self.lineage: if INavigationRoot.providedBy(o): return o return self.root