def get_sys_menu(self): for model, model_admin in self._registry.items(): if getattr(model_admin, 'hidden_menu', False): continue if hasattr(model_admin, 'menu_group'): m_menu_group = model_admin.menu_group or '_default_group' else: m_menu_group = '_default_group' icon = getattr(model_admin, 'model_icon', defs.DEFAULT_MODEL_ICON) app_label = getattr(model_admin, 'app_label', model._meta.app_label) #model_admin.app_label model_dict = { 'title': getattr(model_admin, 'verbose_name', '') or unicode(capfirst(model._meta.verbose_name_plural)), 'url': self.get_model_url(model, "changelist"), 'icon': icon, 'perm': self.get_model_perm(model, 'view'), 'order': model_admin.order, } m_menu = self.sys_menu[app_label] if m_menu_group in m_menu.keys(): m_menu[m_menu_group]['menus'].append(model_dict) else: m_menu['_default_group']['menus'].append(model_dict) for page in self._registry_pages: if getattr(page, 'hidden_menu', False): continue if hasattr(page, 'menu_group'): m_menu_group = page.menu_group or '_default_group' else: m_menu_group = '_default_group' app_label = page.app_label model_dict = { 'title': page.verbose_name, 'url': page.get_page_url(), 'icon': page.icon, 'perm': 'auth.' + (page.perm or 'not_setting_perm'), 'order': page.order, } m_menu = self.sys_menu[app_label] if m_menu_group in m_menu.keys(): m_menu[m_menu_group]['menus'].append(model_dict) else: m_menu['_default_group']['menus'].append(model_dict) for app_menu in self.sys_menu.values(): for menu in app_menu.values(): menu['menus'].sort(key=sortkeypicker(['order'])) self.sys_menu_loaded = True
def get_sys_menu(self): ''' 加载系统所有菜单 ''' for model, model_admin in self._registry.items(): if getattr(model_admin, 'hiden_menu', False) or getattr(model_admin, 'hidden_menu', False): continue if hasattr(model_admin, 'menu_group'): m_menu_group = model_admin.menu_group or '_default_group' else: m_menu_group = '_default_group' icon = getattr(model_admin,'model_icon', defs.DEFAULT_MODEL_ICON) app_label = getattr(model_admin, 'app_label', model._meta.app_label) #model_admin.app_label model_dict = { 'title': getattr(model_admin, 'verbose_name', '') or unicode(capfirst(model._meta.verbose_name_plural)), 'url': self.get_model_url(model, "changelist"), 'icon': icon, 'perm': self.get_model_perm(model, 'view'), 'order': model_admin.order, } m_menu = self.sys_menu[app_label] if m_menu_group in m_menu.keys(): m_menu[m_menu_group]['menus'].append(model_dict) else: m_menu['_default_group']['menus'].append(model_dict) for page in self._registry_pages: if getattr(page, 'hide_menu', False)or getattr(page, 'hidden_menu', False): continue if hasattr(page, 'menu_group'): m_menu_group = page.menu_group or '_default_group' else: m_menu_group = '_default_group' app_label = page.app_label model_dict = { 'title': page.verbose_name, 'url': page.get_page_url(), 'icon': page.icon, 'perm': 'auth.'+ (page.perm or 'not_setting_perm'), 'order': page.order, } m_menu = self.sys_menu[app_label] if m_menu_group in m_menu.keys(): m_menu[m_menu_group]['menus'].append(model_dict) else: m_menu['_default_group']['menus'].append(model_dict) for app_menu in self.sys_menu.values(): for menu in app_menu.values(): menu['menus'].sort(key=sortkeypicker(['order'])) self.sys_menu_loaded = True