def render(request, template, context): context['pages'] = user_profile.get_pages(request, context['profile']) for page in context['pages']: if page['is_active']: context['active_page'] = page break if request.user.is_authenticated(): is_authenticated_user = context['profile'].pk == request.user.pk else: is_authenticated_user = False context['is_authenticated_user'] = is_authenticated_user user_acl = request.user.acl if request.user.is_authenticated(): if is_authenticated_user: context['show_email'] = True else: context['show_email'] = user_acl['can_see_users_emails'] else: context['show_email'] = False context['state'] = get_user_state(context['profile'], user_acl) return django_render(request, template, context)
def decorator(request, *args, **kwargs): pages = user_profile.get_pages(request, kwargs['profile']) for page in pages: if page['is_active']: return f(request, *args, **kwargs) else: # we are trying to display page thats not in nav raise Http404()