Beispiel #1
0
    def breadcrumbs(self):
        context = aq_inner(self.context)

        view_utils = Utils(self.context, self.request)

        crumbs = []
        while context is not None:
            if ISiteRoot.providedBy(context):
                break

            try:
                if utils.isDefaultPage(context, self.request):
                    context = utils.parent(context)
                    continue
            except AttributeError:
                break

            # Some things want to be hidden from the breadcrumbs
            if IHideFromBreadcrumbs.providedBy(context):
                context = utils.parent(context)
                continue

            item_url = view_utils.get_object_url(context)
            try:
                state = api.content.get_state(obj=context)
            except WorkflowException:
                state = None
            label = getattr(context, 'navigation_label', None)
            if not label:
                label = utils.pretty_title_or_id(context, context)
            crumbs.append({
                'absolute_url': item_url,
                'Title': label,
                'state': state
            })
            context = utils.parent(context)

        return list(reversed(crumbs))
Beispiel #2
0
 def do_redirect(self, context):
     utils = Utils(self.context, self.request)
     target = utils.get_object_url(context)
     return self.request.response.redirect(target)
Beispiel #3
0
 def handle_cancel(self, action):
     utils = Utils(self.context, self.request)
     target = utils.get_object_url(self.context)
     return self.request.response.redirect(target)