コード例 #1
0
def render(request, template, context=None, error_page=False):
    context = context or {}

    navigation = site.visible_branches(request)
    sections = navigation[0]

    try:
        actions = navigation[1]
    except IndexError:
        actions = []

    try:
        pages = navigation[2]
    except IndexError:
        pages = []

    context.update({"sections": sections, "actions": actions, "pages": pages})

    if error_page:
        # admittedly haxy solution for displaying navs on error pages
        context["actions"] = []
        context["pages"] = []
        for item in navigation[0]:
            item["is_active"] = False
    else:
        context["active_link"] = None
        for item in navigation[-1]:
            if item["is_active"]:
                context["active_link"] = item
                break

    return dj_render(request, template, context)
コード例 #2
0
def render(request, template, context=None, error_page=False):
    context = context or {}

    navigation = site.visible_branches(request)
    sections = navigation[0]

    try:
        actions = navigation[1]
    except IndexError:
        actions = []

    context.update({"sections": sections, "actions": actions})

    if error_page:
        # admittedly haxy solution for displaying navs on error pages
        context["actions"] = []
        context["pages"] = []
        for item in navigation[0]:
            item["is_active"] = False
    else:
        context["active_link"] = None
        for nav in navigation:
            for item in nav:
                if item["is_active"]:
                    context["active_link"] = item
                    break

    context["ADMIN_MOMENTJS_LOCALE_URL"] = get_admin_moment_locale_url()

    return dj_render(request, template, context)
コード例 #3
0
ファイル: __init__.py プロジェクト: rafalp/Misago
def render(request, template, context=None, error_page=False):
    context = context or {}

    navigation = site.visible_branches(request)
    sections = navigation[0]

    try:
        actions = navigation[1]
    except IndexError:
        actions = []

    try:
        pages = navigation[2]
    except IndexError:
        pages = []

    context.update({"sections": sections, "actions": actions, "pages": pages})

    if error_page:
        # admittedly haxy solution for displaying navs on error pages
        context["actions"] = []
        context["pages"] = []
        for item in navigation[0]:
            item["is_active"] = False
    else:
        context["active_link"] = None
        for item in navigation[-1]:
            if item["is_active"]:
                context["active_link"] = item
                break

    return dj_render(request, template, context)
コード例 #4
0
ファイル: __init__.py プロジェクト: rafalp/Misago
def render(request, template, context=None, error_page=False):
    context = context or {}

    navigation = site.visible_branches(request)
    sections = navigation[0]

    try:
        actions = navigation[1]
    except IndexError:
        actions = []

    context.update({"sections": sections, "actions": actions})

    if error_page:
        # admittedly haxy solution for displaying navs on error pages
        context["actions"] = []
        context["pages"] = []
        for item in sections:
            item["is_active"] = False
    else:
        context["active_link"] = None
        for nav in navigation:
            for item in nav:
                if item["is_active"]:
                    context["active_link"] = item
                    break

    context["ADMIN_MOMENTJS_LOCALE_URL"] = get_admin_moment_locale_url()

    return dj_render(request, template, context)
コード例 #5
0
def render(request, template_name, context=None):
    if request.user.is_authenticated:
        profile = Profile.objects.filter(user=request.user).first()
    else:
        profile = None

    if context is None:
        context = {'profile': profile}  # stworz nowy slownik
    else:
        context['profile'] = profile  # dodaj klucz do istniejacego slownika
    return dj_render(request, template_name, context)
コード例 #6
0
ファイル: errorpages.py プロジェクト: rafalp/Misago
def _csrf_failure(request, reason=""):
    if is_admin_authorized(request):
        update_admin_authorization(request)
        response = render(
            request,
            "misago/admin/errorpages/csrf_failure_authenticated.html",
            error_page=True,
        )
    else:
        response = dj_render(request, "misago/admin/errorpages/csrf_failure.html")

    response.status_code = 403
    return response
コード例 #7
0
def _csrf_failure(request, reason=""):
    if is_admin_authorized(request):
        update_admin_authorization(request)
        response = render(
            request,
            "misago/admin/errorpages/csrf_failure_authenticated.html",
            error_page=True,
        )
    else:
        response = dj_render(request,
                             "misago/admin/errorpages/csrf_failure.html")

    response.status_code = 403
    return response
コード例 #8
0
ファイル: functions.py プロジェクト: miek770/huitcent
def render(request, template, args={}):
    get_token(request)
    post_count = Post.objects.count()
    try:
        contribution = round(100.0*Post.objects.filter(user__exact=request.user).count()/post_count,1)
    except ZeroDivisionError:
        contribution = 0.0
    pref = Preference.objects.get(user__exact=request.user)
    arguments = {
        'user': request.user,
        'forum_list': get_forum_list(request),
        'pending': get_pending_subscriptions(),
        'hidden': get_hidden_threads(),
        'user_count': User.objects.count(),
        'forum_count': Forum.objects.count(),
        'topic_count': Topic.objects.count(),
        'thread_count': Thread.objects.count(),
        'post_count': post_count,
        'contribution': contribution,
        'pref': pref,
        }
    for key in args.keys():
        arguments[key] = args[key]
    return dj_render(request, template, arguments)
コード例 #9
0
def render(request, template_name, context, **kwargs):
    return dj_render(request, template_name, {**context}, **kwargs)
コード例 #10
0
ファイル: common.py プロジェクト: oliwarner/django-mfa2
def render(request, template_name, context, **kwargs):
    return dj_render(request, template_name, {
        'base_template': getattr(settings, 'MFA_BASE_TEMPLATE'),
        **context
    }, **kwargs)