Ejemplo n.º 1
0
    def extra_parent_bread_crumbs_menu_items(self):
        from is_core.menu import LinkMenuItem

        return [
            LinkMenuItem(self.core.model._ui_meta.list_verbose_name % {
                'verbose_name':
                self.core.model._meta.verbose_name,
                'verbose_name_plural':
                self.core.model._meta.verbose_name_plural
            },
                         reverse_pattern('list-%s' %
                                         self.core.menu_group).get_url_string(
                                             self.request),
                         active=False),
            LinkMenuItem(
                self.core.model._ui_meta.edit_verbose_name % {
                    'verbose_name': self.core.model._meta.verbose_name,
                    'verbose_name_plural':
                    self.core.model._meta.verbose_name_plural,
                    'obj':
                    self.core.model.objects.get(pk=self.kwargs.get('pk'))
                },
                reverse_pattern('edit-%s' %
                                self.core.menu_group).get_url_string(
                                    self.request,
                                    kwargs={'pk': self.kwargs.get('pk')}),
                active=False)
        ]
Ejemplo n.º 2
0
    def list_bread_crumbs_menu_item(self):
        from is_core.menu import LinkMenuItem

        return LinkMenuItem(
            self.model._ui_meta.list_verbose_name % {
                'verbose_name': self.model._meta.verbose_name,
                'verbose_name_plural': self.model._meta.verbose_name_plural
            },
            self.core.ui_patterns.get('list').get_url_string(self.request),
            active=not self.add_current_to_breadcrumbs)
Ejemplo n.º 3
0
    def edit_bread_crumbs_menu_item(self):
        from is_core.menu import LinkMenuItem

        return LinkMenuItem(self.model._ui_meta.edit_verbose_name % {
            'verbose_name': self.model._meta.verbose_name,
            'verbose_name_plural': self.model._meta.verbose_name_plural,
            'obj': self.get_obj()
        },
                            self.core.ui_patterns.get('edit').get_url_string(
                                self.request,
                                kwargs={'pk': self.request.kwargs.get('pk')}),
                            active=not self.add_current_to_breadcrumbs)
Ejemplo n.º 4
0
    def get_tab_menu_items(self):
        from is_core.menu import LinkMenuItem

        menu_items = []
        for tab in self.get_tabs():
            if len(tab) == 2:
                tab_title, tab_url = tab
                is_active = self.request.path == tab_url
            else:
                tab_title, tab_url, is_active = tab

            menu_items.append(
                LinkMenuItem(tab_title, tab_url, active=is_active))
        return menu_items
Ejemplo n.º 5
0
    def edit_bread_crumbs_menu_item(self):
        from is_core.menu import LinkMenuItem

        edit_pattern = self.core.ui_patterns.get('edit')
        edit_view = edit_pattern.get_view(self.request)
        parent_obj = self.get_parent_obj()
        if not isinstance(parent_obj, edit_view.model):
            raise GenericViewException(
                'Parent obj must be instance of edit view model')

        return LinkMenuItem(self.model._ui_meta.edit_verbose_name % {
            'verbose_name': edit_view.model._meta.verbose_name,
            'verbose_name_plural': edit_view.model._meta.verbose_name_plural,
            'obj': parent_obj
        },
                            edit_pattern.get_url_string(
                                self.request, kwargs={'pk': parent_obj.pk}),
                            active=not self.add_current_to_breadcrumbs)
Ejemplo n.º 6
0
 def bread_crumbs_menu_items(self):
     if self.add_current_to_breadcrumbs:
         return [
             LinkMenuItem(self.get_title(), self.request.path, active=True)
         ]
     return []
Ejemplo n.º 7
0
    def get_menu_link_item_or_none(self, view):
        from is_core.menu import LinkMenuItem

        return LinkMenuItem(
            self._label, self.get_url(view),
            active=self.is_active(view)) if self.can_show(view) else None
Ejemplo n.º 8
0
 def current_bread_crumb(self):
     return LinkMenuItem(self.get_title(), self.request.path, active=True)
Ejemplo n.º 9
0
 def get_menu_item(self, request, active_group):
     if self.get_show_in_menu(request):
         return LinkMenuItem(self.verbose_name_plural, self.menu_url(request),
                             self.menu_group, active_group == self.menu_group)
Ejemplo n.º 10
0
    def bread_crumbs_menu_items(self):
        from is_core.menu import LinkMenuItem

        return self.extra_parent_bread_crumbs_menu_items() + [
            LinkMenuItem(self.get_title(), self.request.path, active=True)
        ]