Пример #1
0
    def test_proxy(self, user: settings.AUTH_USER_MODEL, request_factory: RequestFactory):
        # user is not staff or student so they will be redirected home
        non_auth_request = request_factory.get("/texts/the_jungle/index.html")
        non_auth_request.user = user
        non_auth_response = proxy(non_auth_request, "/texts/the_jungle/index.html")
        assert non_auth_response.status_code == 302

        # user is student so they will have access to non-home custom urls
        # we assume '/texts/the_jungle/index.html' exists
        student_request = request_factory.get("/texts/the_jungle/index.html")
        user.is_student = True
        student_request.user = user
        student_response = proxy(student_request, "/texts/the_jungle/index.html")
        assert student_response.status_code == 200
        student_content = student_response.content.decode("utf-8")
        assert "The Jungle" in student_content
Пример #2
0
def print_map(request):
    from django.conf import settings
    from proxy.views import proxy
    from layers.models import Layer

    permissions = {}
    params = json.loads(request.body)
    for layer in params['layers']:
        for layer_name in layer['layers']:
            layer_obj = Layer.objects.get(typename=layer_name)
            permissions[layer_obj] = {}
            permissions[layer_obj]['anonymous'] = layer_obj.get_gen_level(ANONYMOUS_USERS)
            permissions[layer_obj]['authenticated'] = layer_obj.get_gen_level(AUTHENTICATED_USERS)
            layer_obj.set_gen_level(ANONYMOUS_USERS,'layer_readonly')
    try:
        resp = proxy(request)
    except Exception, e:
        return HttpResponse('There was an error connecting to the printing server: %s' % e)
Пример #3
0
def print_map(request):
    from django.conf import settings
    from proxy.views import proxy
    from layers.models import Layer

    permissions = {}
    params = json.loads(request.body)
    for layer in params['layers']:
        if settings.OGC_SERVER['default']['LOCATION'] in layer['baseURL']:
            for layer_name in layer['layers']:
                layer_obj = Layer.objects.get(typename=layer_name)
                permissions[layer_obj] = {}
                permissions[layer_obj]['anonymous'] = layer_obj.get_gen_level(ANONYMOUS_USERS)
                permissions[layer_obj]['authenticated'] = layer_obj.get_gen_level(AUTHENTICATED_USERS)
                layer_obj.set_gen_level(ANONYMOUS_USERS,'layer_readonly')
    try:
        resp =  proxy(request)
    except Exception, e:
        return HttpResponse('There was an error connecting to the printing server')
Пример #4
0
def print_map(request):
    from django.conf import settings
    from proxy.views import proxy
    from layers.models import Layer

    permissions = {}
    params = json.loads(request.body)
    for layer in params["layers"]:
        if settings.GEOSERVER_BASE_URL in layer["baseURL"]:
            for layer_name in layer["layers"]:
                layer_obj = Layer.objects.get(typename=layer_name)
                permissions[layer_obj] = {}
                permissions[layer_obj]["anonymous"] = layer_obj.get_gen_level(ANONYMOUS_USERS)
                permissions[layer_obj]["authenticated"] = layer_obj.get_gen_level(AUTHENTICATED_USERS)
                layer_obj.set_gen_level(ANONYMOUS_USERS, "layer_readonly")
    try:
        resp = proxy(request)
    except Exception, e:
        return HttpResponse("There was an error connecting to the printing server")
Пример #5
0
def print_map(request):
    from proxy.views import proxy
    from layers.models import Layer

    permissions = {}
    params = json.loads(request.body)
    for layer in params['layers']:
        if ogc_server_settings.LOCATION in layer['baseURL']:
            for layer_name in layer['layers']:
                layer_obj = Layer.objects.get(typename=layer_name)
                permissions[layer_obj] = _perms_info_json(layer_obj)
                layer_obj.set_default_permissions()
    try:
        resp = proxy(request)
    except Exception:
        return HttpResponse('There was an error connecting to the printing server')
    finally:
        for layer_obj in permissions.keys():
            layer_obj.set_permissions(json.loads(permissions[layer_obj]))

    return resp
Пример #6
0
def print_map(request):
    from proxy.views import proxy
    from layers.models import Layer

    permissions = {}
    params = json.loads(request.body)
    for layer in params['layers']:
        if 'baseURL' in layer:
            if ogc_server_settings.LOCATION in layer['baseURL']:
                for layer_name in layer['layers']:
                    layer_obj = Layer.objects.get(alternate=layer_name)
                    permissions[layer_obj] = _perms_info_json(layer_obj)
                    layer_obj.set_default_permissions()
    try:
        resp = proxy(request)
    except Exception:
        return HttpResponse('There was an error connecting to the printing server')
    finally:
        for layer_obj in permissions.keys():
            layer_obj.set_permissions(json.loads(permissions[layer_obj]))

    return resp