def basic_context(request, top_active=None): if top_active is not None: request.session['top_active'] = top_active elif 'top_active' in request.session: top_active = request.session['top_active'] context = {} if 'message' in request.session: context['info'] = request.session.pop('info') if 'success' in request.session: context['success'] = request.session.pop('success') if 'errors' in request.session: context['errors'] = request.session.pop('errors') context['base_template'] = 'sk_page_base.html' if hasattr(settings, 'PAGE_BASE'): context['base_template'] = settings.PAGE_BASE raw_menu = [] for item in settings.TOP_MENU: if 'groups' in item: if HotDjango.is_allowed_hot(request.user, permitted_groups=item['groups']): raw_menu.append(item) else: raw_menu.append(item) if request.user.is_staff: raw_menu.append({ 'url': 'admin:index', 'name': 'Staff Admin', 'glyph': 'wrench' }) top_menu = [] for item in raw_menu: menu_item = {'url': reverse(item['url']), 'name': item['name']} if 'glyph' in item: menu_item['glyph'] = item['glyph'] if item['url'] == top_active: menu_item['class'] = 'active' top_menu.append(menu_item) context['top_menu'] = top_menu context['site_title'] = settings.SITE_TITLE return context
def basic_context(request, top_active = None): if top_active is not None: request.session['top_active'] = top_active elif 'top_active' in request.session: top_active = request.session['top_active'] context = {} if 'message' in request.session: context['info'] = request.session.pop('info') if 'success' in request.session: context['success'] = request.session.pop('success') if 'errors' in request.session: context['errors'] = request.session.pop('errors') context['base_template'] = 'sk_page_base.html' if hasattr(settings, 'PAGE_BASE'): context['base_template'] = settings.PAGE_BASE raw_menu = [] for item in settings.TOP_MENU: if 'groups' in item: if HotDjango.is_allowed_hot(request.user, permitted_groups=item['groups']): raw_menu.append(item) else: raw_menu.append(item) if request.user.is_staff: raw_menu.append({'url': 'admin:index', 'name': 'Staff Admin', 'glyph':'wrench'}) top_menu = [] for item in raw_menu: menu_item = {'url': reverse(item['url']), 'name': item['name']} if 'glyph' in item: menu_item['glyph'] = item['glyph'] if item['url'] == top_active: menu_item['class'] = 'active' top_menu.append(menu_item) context['top_menu'] = top_menu context['site_title'] = settings.SITE_TITLE return context
def has_permission(self, request, view): if request.user and request.user.is_authenticated(): return HotDjango.is_allowed_hot(request.user) return False
def is_allowed(self): return HotDjango.is_allowed_hot(self.request.user)