Ejemplo n.º 1
0
    else:
        region_code = instance.itree_region_default

    rslt = {}
    if not dbh:
        rslt = {'benefits': {}, 'error': 'MISSING_DBH'}
    elif not otm_code:
        rslt = {'benefits': {}, 'error': 'MISSING_SPECIES'}
    else:
        rslt = {'benefits':
                _benefits_for_trees(
                    [{'species__otm_code': otm_code,
                      'diameter': dbh,
                      'itree_region_code': region_code}])}

    return rslt


def within_itree_regions(request):
    x = request.GET.get('x', None)
    y = request.GET.get('y', None)
    return (bool(x) and bool(y) and
            ITreeRegion.objects
            .filter(geometry__contains=Point(float(x),
                                             float(y))).exists())

within_itree_regions_view = json_api_call(within_itree_regions)

tree_benefits_view = json_api_call(
    instance_request(strip_request(tree_benefits)))
Ejemplo n.º 2
0
    return {'start_status': 'OK', 'job_id': job.pk}


def check_export(request, instance, job_id):

    job = get_object_or_404(ExportJob, pk=job_id)

    # if a job has a user, it means the user must
    # be authenticated so only the job user can
    # retrieve the export
    if job.user and job.user != request.user:
        return {'status': 'ERROR',
                'message': 'Job not initiated by user',
                'url': None}

    else:
        return {'status': ExportJob.STATUS_STRINGS[job.status],
                'message': ExportJob.STATUS_CHOICES[job.status],
                'url': job.get_url_if_ready()}


begin_export_endpoint = json_api_call(
    instance_request(
        requires_feature('exports')(
            begin_export)))
check_export_endpoint = json_api_call(
    instance_request(
        requires_feature('exports')(
            check_export)))
Ejemplo n.º 3
0
    #       the same string. In the future, they'll grab
    #       from the instance config

    allowed_pages = ["Resources", "FAQ", "About"]

    if page not in allowed_pages:
        raise Http404()

    return {"content": trans("There is no content for this page yet"), "title": page}


def index(request, instance):
    return HttpResponseRedirect(reverse("map", kwargs={"instance_url_name": instance.url_name}))


edits_view = instance_request(requires_feature("recent_edits_report")(render_template("treemap/edits.html", edits)))

index_view = instance_request(index)

map_view = instance_request(render_template("treemap/map.html", _get_map_view_context))

get_plot_detail_view = instance_request(render_template("treemap/plot_detail.html", plot_detail))

edit_plot_detail_view = login_required(
    instance_request(creates_instance_user(render_template("treemap/plot_detail.html", plot_detail)))
)

get_plot_eco_view = instance_request(etag(_plot_hash)(render_template("treemap/partials/plot_eco.html", plot_detail)))

get_plot_sidebar_view = instance_request(
    etag(_plot_hash)(render_template("treemap/partials/sidebar.html", plot_detail))