Esempio n. 1
0
def map(request):
    data = {}
    try:
        if not request.user.is_authenticated():
            user = models.GislabUser.get_guest_user()
            if user:
                login(request, user)
            else:
                raise RuntimeError("Anonymous user is not configured")
        data['user'] = get_user_data(request.user)
        data['project'] = get_project(request)

    except InvalidProjectException as e:
        return render(
            request,
            "viewer/4xx.html",
            {'message': "Error when loading project or project does not exist"},
            status=404,
            content_type="text/html"
        )

    templateData = {
        'data': data,
        'jsonData': json.dumps(data)
    }
    return render(
        request,
        "viewer/index.html",
        templateData,
        status=200,
        content_type="text/html"
    )
Esempio n. 2
0
def map(request):
    data = {}
    try:
        if not request.user.is_authenticated():
            user = models.GisquickUser.get_guest_user()
            if user:
                login(request, user)
            else:
                raise RuntimeError("Anonymous user is not configured")
        data['user'] = get_user_data(request.user)
        data['project'] = get_project(request)
        data['app'] = {
            'version': webgis.VERSION,
            'reset_password_url': getattr(settings, 'RESET_PASSWORD_URL', '')
        }

    except InvalidProjectException as e:
        return render(
            request,
            "viewer/4xx.html", {
                'message':
                "Error when loading project or project does not exist"
            },
            status=404,
            content_type="text/html")

    templateData = {'data': data, 'jsonData': json.dumps(data)}
    return render(request,
                  "viewer/index.html",
                  templateData,
                  status=200,
                  content_type="text/html")
Esempio n. 3
0
def map(request):
    data = {}
    try:
        if not request.user.is_authenticated():
            user = models.GisquickUser.get_guest_user()
            if user:
                login(request, user)
            else:
                raise RuntimeError("Anonymous user is not configured")
        data['user'] = get_user_data(request.user)
        data['project'] = get_project(request)

    except InvalidProjectException as e:
        return render(
            request,
            "viewer/4xx.html", {
                'message':
                "Error when loading project or project does not exist"
            },
            status=404,
            content_type="text/html")

    templateData = {'data': data, 'jsonData': json.dumps(data)}
    return render(request,
                  "viewer/index.html",
                  templateData,
                  status=200,
                  content_type="text/html")
Esempio n. 4
0
def map(request):
    try:
        project_data = get_project(request)
        return render(
            request,
            "viewer/index.html",
            {
                'user': request.user,
                'project': json.dumps(project_data)
            },
            content_type="text/html"
        )
    except LoginRequiredException:
        # redirect to login page
        return HttpResponseRedirect(
            set_query_parameters(
                reverse('login'),
                {'next': request.get_full_path()}
            )
        )
    except AccessDeniedException:
        msg = "You don't have permissions for this project"
        status = 403
    except InvalidProjectException:
        msg = "Error when loading project or project does not exist"
        status = 404
    except ProjectExpiredException:
        msg = "Project has reached expiration date.",
        status = 410
    except Exception, e:
        msg = "Server error"
        #TODO: log exception error
        raise
        status = 500
Esempio n. 5
0
def map(request):
    data = {}
    try:
        if not request.user.is_authenticated():
            user = models.GislabUser.get_guest_user()
            if user:
                login(request, user)
            else:
                raise RuntimeError("Anonymous user is not configured")
        data['user'] = get_user_data(request.user)
        data['project'] = get_project(request)

    except InvalidProjectException:
        raiseHttp404
    except Exception, e:
        #TODO: log exception error
        raise
Esempio n. 6
0
def project_json(request):
    try:
        project_data = get_project(request)
        return JsonResponse(project_data, status=project_data['status'])
    except InvalidProjectException:
        return HttpResponse('Not Found', status=404)
Esempio n. 7
0
def project_json(request):
    try:
        project_data = get_project(request)
        return JsonResponse(project_data, status=project_data['status'])
    except InvalidProjectException:
        raise Http404
Esempio n. 8
0
def project_json(request):
    try:
        project_data = get_project(request)
        return JsonResponse(project_data)
    except LoginRequiredException:
        return HttpResponse('Authentication required', status=401)
Esempio n. 9
0
def project_json(request):
    try:
        project_data = get_project(request)
        return JsonResponse(project_data)
    except LoginRequiredException:
        return HttpResponse("Authentication required", status=401)
Esempio n. 10
0
def project_json(request):
    try:
        project_data = get_project(request)
        return JsonResponse(project_data, status=project_data['status'])
    except InvalidProjectException:
        return HttpResponse('Not Found', status=404)