示例#1
0
def json_api_edit(req_function):
    """
    Wraps view function for an AJAX call which modifies data.
    """
    return do(
        login_or_401,
        json_api_call,
        creates_instance_user,
        req_function)
示例#2
0
文件: views.py 项目: grafuls/OTM2
                             'last_name',
                             'email',
                             'body'])
    writer.writeheader()

    for relic in relics:
        user = User.objects.get(pk=relic.otm2_model_id)
        if relic.otm1_username == user.username:
            continue
        assert relic.email.lower() == user.email.lower()
        row = {
            'otm1_user_id': relic.otm1_model_id,
            'otm2_model_id': user.pk,
            'otm1_username': relic.otm1_username,
            'last_login': user.last_login,
            'otm2_username': user.username,
            'first_name': user.first_name,
            'last_name': user.last_name,
            'email': user.email,
        }
        body = render_email_body(user, instance)
        row['body'] = body
        writer.writerow(row)

    return response

user_csv_endpoint = do(
    require_http_method("GET"),
    admin_instance_request,
    user_csv)
示例#3
0
logged_in_api_do = partial(do, csrf_exempt, set_api_version,
                           check_signature_and_require_login, json_api_call)

plots_closest_to_point_endpoint = instance_api_do(plots_closest_to_point)

instances_closest_to_point_endpoint = api_do(
    instances_closest_to_point)

public_instances_endpoint = api_do(public_instances)

instance_info_endpoint = instance_api_do(instance_info)

plots_endpoint = instance_api_do(
    route(GET=get_plot_list,
          POST=do(
              login_required,
              update_or_create_plot)))


plot_endpoint = instance_api_do(
    route(GET=get_plot,
          ELSE=do(login_required,
                  route(
                      PUT=update_or_create_plot,
                      DELETE=remove_plot))))

species_list_endpoint = instance_api_do(
    route(GET=species_list))

user_endpoint = api_do(
    route(
示例#4
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 = do(json_api_call, instance_request,
                           requires_feature('exports'), begin_export)

check_export_endpoint = do(json_api_call, instance_request,
                           requires_feature('exports'), check_export)
示例#5
0
# Note that API requests going to private instances require
# authentication "login_optional" before they can access they
# instance data

instance_api_do = partial(do, check_signature, instance_request, json_api_call)

plots_closest_to_point_endpoint = instance_api_do(plots_closest_to_point)

instances_closest_to_point_endpoint = instance_api_do(
    instances_closest_to_point)

instance_info_endpoint = instance_api_do(instance_info)

plots_endpoint = instance_api_do(
    route(GET=get_plot_list, POST=do(login_required, update_or_create_plot)))

plot_endpoint = instance_api_do(
    route(GET=get_plot,
          ELSE=do(login_required,
                  route(PUT=update_or_create_plot, DELETE=remove_plot))))

species_list_endpoint = instance_api_do(route(GET=species_list))

user_endpoint = do(
    check_signature, json_api_call,
    route(GET=do(login_required, user_info),
          POST=do(return_400_if_validation_errors, create_user)))

update_user_endpoint = do(check_signature_and_require_login, json_api_call,
                          return_400_if_validation_errors,
示例#6
0
文件: __init__.py 项目: atogle/OTM2
add_map_feature_photo_do = partial(
    do,
    require_http_method("POST"),
    login_or_401,
    instance_request,
    creates_instance_user,
    render_template('treemap/partials/photo_carousel.html'))

#####################################
# misc content views
#####################################

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

index_view = instance_request(index)

map_view = do(
    instance_request,
    render_template('treemap/map.html'),
    get_map_view_context)

static_page_view = do(
    instance_request,
    render_template('treemap/staticpage.html'),
    static_page)
示例#7
0
                 json_api_call)

logged_in_api_do = partial(do, csrf_exempt, set_api_version,
                           check_signature_and_require_login, json_api_call)

plots_closest_to_point_endpoint = instance_api_do(plots_closest_to_point)

instances_closest_to_point_endpoint = api_do(
    instances_closest_to_point)

instance_info_endpoint = instance_api_do(instance_info)

plots_endpoint = instance_api_do(
    route(GET=get_plot_list,
          POST=do(
              login_required,
              update_or_create_plot)))


plot_endpoint = instance_api_do(
    route(GET=get_plot,
          ELSE=do(login_required,
                  route(
                      PUT=update_or_create_plot,
                      DELETE=remove_plot))))

species_list_endpoint = instance_api_do(
    route(GET=species_list))

user_endpoint = api_do(
    route(
示例#8
0
文件: views.py 项目: cgarrard/OTM2
# instance data

instance_api_do = partial(do, check_signature,
                          instance_request, json_api_call)

plots_closest_to_point_endpoint = instance_api_do(plots_closest_to_point)

instances_closest_to_point_endpoint = instance_api_do(
    instances_closest_to_point)

instance_info_endpoint = instance_api_do(instance_info)

plots_endpoint = instance_api_do(
    route(GET=get_plot_list,
          POST=do(
              login_required,
              update_or_create_plot)))


plot_endpoint = instance_api_do(
    route(GET=get_plot,
          ELSE=do(login_required,
                  route(
                      PUT=update_or_create_plot,
                      DELETE=remove_plot))))

species_list_endpoint = instance_api_do(
    route(GET=species_list))

user_endpoint = do(
    check_signature,
示例#9
0
from treemap.views.map_feature import (
    render_map_feature_detail, render_map_feature_add,
    update_map_feature_detail, map_feature_detail, plot_detail,
    delete_map_feature, map_feature_popup, add_map_feature, map_feature_hash,
    add_map_feature_photo)

add_map_feature_photo_do = partial(
    do, require_http_method("POST"), login_or_401, instance_request,
    creates_instance_user,
    render_template('treemap/partials/photo_carousel.html'))

#####################################
# misc content views
#####################################

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

index_view = instance_request(index)

map_view = do(instance_request, render_template('treemap/map.html'),
              get_map_view_context)

static_page_view = do(instance_request,
                      render_template('treemap/staticpage.html'), static_page)

instance_not_available_view = render_template(
    'treemap/instance_not_available.html')()

landing_view = render_template('base.html')()

unsupported_view = render_template('treemap/unsupported.html')()
示例#10
0
文件: views.py 项目: PyBulls/OTM2
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 = do(
    json_api_call,
    instance_request,
    requires_feature('exports'),
    begin_export)

check_export_endpoint = do(
    json_api_call,
    instance_request,
    requires_feature('exports'),
    check_export)