def init_with_context(self, context): """ Initializes the icon list. """ super(CmsAppIconList, self).init_with_context(context) apps = self.children cms_apps = [a for a in apps if is_cms_app(a['name'])] non_cms_apps = [a for a in apps if a not in cms_apps] if cms_apps: # Group the models of all CMS apps in one group. cms_models = [] for app in cms_apps: cms_models += app['models'] sort_cms_models(cms_models) single_cms_app = { 'name': "Modules", 'title': "Modules", 'url': "", 'models': cms_models } # Put remaining groups after the first CMS group. self.children = [single_cms_app] + non_cms_apps
def init_with_context(self, context): """ Initializes the icon list. """ super(CmsAppIconList, self).init_with_context(context) apps = self.children cms_apps = [a for a in apps if is_cms_app(a["name"])] non_cms_apps = [a for a in apps if a not in cms_apps] if cms_apps: # Group the models of all CMS apps in one group. cms_models = [] for app in cms_apps: cms_models += app["models"] sort_cms_models(cms_models) single_cms_app = {"name": "Modules", "title": "Modules", "url": "", "models": cms_models} # Put remaining groups after the first CMS group. self.children = [single_cms_app] + non_cms_apps
def init_with_context(self, context): """ Initialize the menu. """ listitems = self._visible_models(context['request']) # Convert to a similar data structure like the dashboard icons have. # This allows sorting the items identically. models = [{ 'name': model._meta.module_name, 'app_name': model._meta.app_label, 'title': capfirst(model._meta.verbose_name_plural), 'url': self._get_admin_change_url(model, context) } for model, perms in listitems if perms['change']] # Sort models. sort_cms_models(models) # Convert to items for model in models: self.children.append( items.MenuItem(title=model['title'], url=model['url']))
def init_with_context(self, context): """ Initialize the menu. """ listitems = self._visible_models(context['request']) # Convert to a similar data structure like the dashboard icons have. # This allows sorting the items identically. models = [ { 'name': model._meta.module_name, 'app_name': model._meta.app_label, 'title': capfirst(model._meta.verbose_name_plural), 'url': self._get_admin_change_url(model, context) } for model, perms in listitems if perms['change'] ] # Sort models. sort_cms_models(models) # Convert to items for model in models: self.children.append(items.MenuItem(title=model['title'], url=model['url']))
def init_with_context(self, context): """ Initialize the menu. """ # Apply the include/exclude patterns: listitems = self._visible_models(context["request"]) # Convert to a similar data structure like the dashboard icons have. # This allows sorting the items identically. models = [{ "name": model._meta.model_name, "app_name": model._meta.app_label, "title": capfirst(model._meta.verbose_name_plural), "url": self._get_admin_change_url(model, context), } for model, perms in listitems if self.is_item_visible(model, perms)] # Sort models. sort_cms_models(models) # Convert to items for model in models: self.children.append( items.MenuItem(title=model["title"], url=model["url"]))