Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
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)
Esempio n. 6
0
    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
Esempio n. 7
0
File: util.py Progetto: igudym/Kotti
 def navigation_root(self):
     for o in self.lineage:
         if INavigationRoot.providedBy(o):
             return o
     return self.root
Esempio n. 8
0
 def navigation_root(self):
     for o in self.lineage:
         if INavigationRoot.providedBy(o):
             return o
     return self.root