예제 #1
0
def test_is_admin_user_func(rf, admin_user, regular_user):
    get_default_shop()
    regular_user.is_staff = True
    request = apply_request_middleware(rf.post("/"), user=regular_user)
    assert not is_admin_user(request)
    assert not request.is_admin_user
    assert not is_admin_user(request)

    request = apply_request_middleware(rf.post("/"), user=admin_user)
    assert is_admin_user(request)
    assert request.is_admin_user
    assert is_admin_user(request)

    request = apply_request_middleware(rf.post("/"))
    assert not is_admin_user(request)
예제 #2
0
파일: misc.py 프로젝트: ruqaiya/shuup
def toggle_all_seeing(request):
    return_url = request.META["HTTP_REFERER"]
    if not is_admin_user(request):
        return HttpResponseRedirect(return_url)

    toggle_all_seeing_for_user(request.user)
    return HttpResponseRedirect(return_url)
예제 #3
0
def toggle_all_seeing(request):
    return_url = request.META["HTTP_REFERER"]
    if not is_admin_user(request):
        return HttpResponseRedirect(return_url)

    toggle_all_seeing_for_user(request.user)
    return HttpResponseRedirect(return_url)
예제 #4
0
def toggle_all_seeing(request):
    return_url = request.META["HTTP_REFERER"]
    if not is_admin_user(request):
        return HttpResponseRedirect(return_url)
    all_seeing_key = "is_all_seeing:%d" % request.user.pk
    is_all_seeing = not configuration.get(None, all_seeing_key, False)
    configuration.set(None, all_seeing_key, is_all_seeing)
    return HttpResponseRedirect(return_url)
예제 #5
0
def force_person_contact(request):
    return_url = request.META["HTTP_REFERER"]
    if not is_admin_user(request):
        return HttpResponseRedirect(return_url)

    user = request.user
    force_person_contact_for_user(user, True)
    force_anonymous_contact_for_user(user, False)
    return HttpResponseRedirect(return_url)
예제 #6
0
파일: misc.py 프로젝트: ruqaiya/shuup
def force_person_contact(request):
    return_url = request.META["HTTP_REFERER"]
    if not is_admin_user(request):
        return HttpResponseRedirect(return_url)

    user = request.user
    force_person_contact_for_user(user, True)
    force_anonymous_contact_for_user(user, False)
    return HttpResponseRedirect(return_url)
예제 #7
0
def could_edit(request):
    """
    Return true if the context of the given request would allow Xtheme editing.

    :param request: HTTP request
    :type request: django.http.HttpRequest
    :return: Would allow editing?
    :rtype: bool
    """
    return is_admin_user(request)
예제 #8
0
파일: editing.py 프로젝트: ruqaiya/shuup
def could_edit(request):
    """
    Return true if the context of the given request would allow Xtheme editing.

    :param request: HTTP request
    :type request: django.http.HttpRequest
    :return: Would allow editing?
    :rtype: bool
    """
    return is_admin_user(request)
예제 #9
0
def force_company_contact(request):
    return_url = request.META["HTTP_REFERER"]
    if not is_admin_user(request):
        return HttpResponseRedirect(return_url)

    user = request.user
    force_anonymous_contact_for_user(user, False)
    force_person_contact_for_user(user, False)

    get_company_contact_for_shop_staff(request.shop, user)
    return HttpResponseRedirect(return_url)
예제 #10
0
파일: misc.py 프로젝트: ruqaiya/shuup
def force_company_contact(request):
    return_url = request.META["HTTP_REFERER"]
    if not is_admin_user(request):
        return HttpResponseRedirect(return_url)

    user = request.user
    force_anonymous_contact_for_user(user, False)
    force_person_contact_for_user(user, False)

    get_company_contact_for_shop_staff(request.shop, user)
    return HttpResponseRedirect(return_url)
예제 #11
0
파일: middleware.py 프로젝트: ruqaiya/shuup
    def _get_maintenance_response(self, request, view_func):
        if settings.DEBUG:
            # Allow media and static accesses in debug mode
            if request.path.startswith("/media") or request.path.startswith("/static"):
                return None
        if getattr(view_func, "maintenance_mode_exempt", False):
            return None
        if "login" in view_func.__name__:
            return None
        resolver_match = getattr(request, "resolver_match", None)
        if resolver_match and resolver_match.app_name == "shuup_admin":
            return None

        if request.shop.maintenance_mode and not is_admin_user(request):
            return HttpResponse(loader.render_to_string("shuup/front/maintenance.jinja", request=request), status=503)
예제 #12
0
    def _get_maintenance_response(self, request, view_func):
        if settings.DEBUG:
            # Allow media and static accesses in debug mode
            if request.path.startswith("/media") or request.path.startswith("/static"):
                return None
        if getattr(view_func, "maintenance_mode_exempt", False):
            return None
        if "login" in view_func.__name__:
            return None
        resolver_match = getattr(request, "resolver_match", None)
        if resolver_match and resolver_match.app_name == "shuup_admin":
            return None

        if request.shop.maintenance_mode and not is_admin_user(request):
            return HttpResponse(loader.render_to_string("shuup/front/maintenance.jinja", request=request), status=503)
예제 #13
0
def is_shop_admin(context):
    return is_admin_user(context["request"])
예제 #14
0
파일: general.py 프로젝트: ruqaiya/shuup
def is_shop_admin(context):
    return is_admin_user(context["request"])