def render(self, context): menu = get_menu(self.menu_name, get_admin_site_name(context)) if menu and menu.is_user_allowed(context.get('request').user): enabled = True else: enabled = False context['wpadmin_is_%s_menu_enabled' % self.menu_name] = enabled return ''
def wpadmin_render_left_menu(context): menu = get_menu('left', get_admin_site_name(context)) if menu: menu.init_with_context(context) context.update({ 'menu': menu, 'is_user_allowed': menu.is_user_allowed(context.get('request').user), }) return context
def wpadmin_render_top_menu(context): menu = get_menu('top', get_admin_site_name(context)) if not menu: from wpadmin.menu.menus import DefaultTopMenu menu = DefaultTopMenu() menu.init_with_context(context) context.update({ 'menu': menu, 'is_user_allowed': menu.is_user_allowed(context.get('request').user), }) return context
def wpadmin_render_left_menu(context): menu = get_menu('left', get_admin_site_name(context)) if menu: menu.init_with_context(context) context.update({ 'menu': menu, 'is_user_allowed': menu.is_user_allowed(context.get('request').user), }) from cms.models import AdminStaff cur_user = context.get('request').user if not cur_user.is_anonymous(): kefu = AdminStaff.objects.filter(user=cur_user) if kefu.exists(): context.update({ 'kefu': kefu[0], }) return context