def suit_time(parser, token): return NowNode(get_config('HEADER_TIME_FORMAT'))
def suit_date(parser, token): return NowNode(get_config('HEADER_DATE_FORMAT'))
def suit_conf(name): value = get_config(name) return mark_safe(value) if isinstance(value, six.string_types) else value
def get_app_list(context, request): """ :type request: WSGIRequest """ if not isinstance(request, WSGIRequest): return None template_response = admin.site.index(request) try: app_list = template_response.context_data['app_list'] except Exception: return try: current_app = context['app_label'].lower() except Exception: current_app = None try: curr_model_name_pl = context['opts'].verbose_name_plural.lower() except Exception: curr_model_name_pl = None exclude = suit.get_config('MENU_EXCLUDE') open_first_child = suit.get_config('MENU_OPEN_FIRST_CHILD') icons = suit.get_config('MENU_ICONS') menu_order = suit.get_config('MENU_ORDER') for app in app_list: app_name = app['name'].lower() # Exclude if in exclude list if exclude and app_name in exclude: app_list.remove(app) continue # Set icon if configured if icons and app_name in icons: app['icon'] = icons[app_name] # Mark as active by url or app name match app['is_active'] = request.path == app['app_url'] app['is_active'] |= current_app == app_name # Iterate models for model in app['models']: # Exclude if in exclude list model_full_name = '%s.%s' % (app_name, get_model_name(model)) if exclude and model_full_name in exclude: app['models'].remove(model) continue # Mark as active by url or model plural name match model['is_active'] = request.path == model['admin_url'] model['is_active'] |= curr_model_name_pl == model['name'].lower() # Reorder menu if menu_order: app_list = reorder_apps(app_list, menu_order) # Set first child url unless MENU_PARENT_LINK = True if open_first_child: for app in app_list: app['app_url'] = app['models'][0]['admin_url'] return app_list
def suit_conf(name): value = get_config(name) return mark_safe(value) if isinstance(value, basestring) else value
def init_config(self): self.conf_exclude = get_config('MENU_EXCLUDE') self.conf_open_first_child = get_config('MENU_OPEN_FIRST_CHILD') self.conf_icons = get_config('MENU_ICONS') self.conf_menu_order = get_config('MENU_ORDER')