예제 #1
0
def add_par(request, parentObject, otype, stype):

    all_schema = Schema.objects.filter(type=stype, immutable=False)

    if 'schema_id' in request.GET:
        schema_id = request.GET['schema_id']
    elif all_schema.count() > 0:
        schema_id = all_schema[0].id
    else:
        return HttpResponse(render_response_index(
            request, 'tardis_portal/ajax/parameter_set_unavailable.html', {}))

    schema = Schema.objects.get(id=schema_id)

    parameternames = ParameterName.objects.filter(
        schema__namespace=schema.namespace)

    success = False
    valid = True

    if request.method == 'POST':
        request = remove_csrf_token(request)

        class DynamicForm(create_datafile_add_form(
                schema.namespace, parentObject, request=request)):
            pass

        form = DynamicForm(request.POST)

        if form.is_valid():
            save_datafile_add_form(schema.namespace, parentObject, request)

            success = True
        else:
            valid = False

    else:

        class DynamicForm(create_datafile_add_form(
                schema.namespace, parentObject)):
            pass

        form = DynamicForm()

    c = {
        'schema': schema,
        'form': form,
        'parameternames': parameternames,
        'type': otype,
        'success': success,
        'valid': valid,
        'parentObject': parentObject,
        'all_schema': all_schema,
        'schema_id': schema.id,
    }

    return HttpResponse(render_response_index(request,
                        'tardis_portal/ajax/parameteradd.html', c))
예제 #2
0
def add_par(request, parentObject, otype, stype):

    all_schema = Schema.objects.filter(type=stype, immutable=False)

    if "schema_id" in request.GET:
        schema_id = request.GET["schema_id"]
    elif all_schema.count() > 0:
        schema_id = all_schema[0].id
    else:
        return HttpResponse(render_response_index(request, "tardis_portal/ajax/parameter_set_unavailable.html", {}))

    schema = Schema.objects.get(id=schema_id)

    parameternames = ParameterName.objects.filter(schema__namespace=schema.namespace)

    success = False
    valid = True

    if request.method == "POST":
        request = remove_csrf_token(request)

        class DynamicForm(create_datafile_add_form(schema.namespace, parentObject, request=request)):
            pass

        form = DynamicForm(request.POST)

        if form.is_valid():
            save_datafile_add_form(schema.namespace, parentObject, request)

            success = True
        else:
            valid = False

    else:

        class DynamicForm(create_datafile_add_form(schema.namespace, parentObject)):
            pass

        form = DynamicForm()

    c = {
        "schema": schema,
        "form": form,
        "parameternames": parameternames,
        "type": otype,
        "success": success,
        "valid": valid,
        "parentObject": parentObject,
        "all_schema": all_schema,
        "schema_id": schema.id,
    }

    return HttpResponse(render_response_index(request, "tardis_portal/ajax/parameteradd.html", c))
예제 #3
0
def edit_parameters(request, parameterset, otype):

    parameternames = ParameterName.objects.filter(
        schema__namespace=parameterset.schema.namespace)
    success = False
    valid = True

    if request.method == 'POST':
        request = remove_csrf_token(request)

        class DynamicForm(create_parameterset_edit_form(
                parameterset, request=request)):
            pass

        form = DynamicForm(request.POST)

        if form.is_valid():
            save_datafile_edit_form(parameterset, request)

            success = True
        else:
            valid = False

    else:

        class DynamicForm(create_parameterset_edit_form(
                parameterset)):
            pass

        form = DynamicForm()

    c = {
        'schema': parameterset.schema,
        'form': form,
        'parameternames': parameternames,
        'type': otype,
        'success': success,
        'parameterset_id': parameterset.id,
        'valid': valid,
    }

    return HttpResponse(render_response_index(request,
                        'tardis_portal/ajax/parameteredit.html', c))
예제 #4
0
def edit_parameters(request, parameterset, otype):

    parameternames = ParameterName.objects.filter(
        schema__namespace=parameterset.schema.namespace)
    success = False
    valid = True

    if request.method == 'POST':
        request = remove_csrf_token(request)

        class DynamicForm(
                create_parameterset_edit_form(parameterset, request=request)):
            pass

        form = DynamicForm(request.POST)

        if form.is_valid():
            save_datafile_edit_form(parameterset, request)

            success = True
        else:
            valid = False

    else:

        class DynamicForm(create_parameterset_edit_form(parameterset)):
            pass

        form = DynamicForm()

    c = {
        'schema': parameterset.schema,
        'form': form,
        'parameternames': parameternames,
        'type': otype,
        'success': success,
        'parameterset_id': parameterset.id,
        'valid': valid,
    }

    return HttpResponse(
        render_response_index(request, 'tardis_portal/ajax/parameteredit.html',
                              c))
예제 #5
0
def edit_parameters(request, parameterset, otype):

    parameternames = ParameterName.objects.filter(schema__namespace=parameterset.schema.namespace)
    success = False
    valid = True

    if request.method == "POST":
        request = remove_csrf_token(request)

        class DynamicForm(create_parameterset_edit_form(parameterset, request=request)):
            pass

        form = DynamicForm(request.POST)

        if form.is_valid():
            save_datafile_edit_form(parameterset, request)

            success = True
        else:
            valid = False

    else:

        class DynamicForm(create_parameterset_edit_form(parameterset)):
            pass

        form = DynamicForm()

    c = {
        "schema": parameterset.schema,
        "form": form,
        "parameternames": parameternames,
        "type": otype,
        "success": success,
        "parameterset_id": parameterset.id,
        "valid": valid,
    }

    return HttpResponse(render_response_index(request, "tardis_portal/ajax/parameteredit.html", c))
예제 #6
0
def add_par(request, parentObject, otype, stype):

    all_schema = Schema.objects.filter(type=stype, immutable=False)

    if 'schema_id' in request.GET:
        schema_id = request.GET['schema_id']
    elif all_schema.count() > 0:
        schema_id = all_schema[0].id
    else:
        return HttpResponse(
            render_response_index(
                request, 'tardis_portal/ajax/parameter_set_unavailable.html',
                {}))

    schema = Schema.objects.get(id=schema_id)

    parameternames = ParameterName.objects.filter(
        schema__namespace=schema.namespace)

    success = False
    valid = True

    if request.method == 'POST':
        request = remove_csrf_token(request)

        class DynamicForm(
                create_datafile_add_form(schema.namespace,
                                         parentObject,
                                         request=request)):
            pass

        form = DynamicForm(request.POST)

        if form.is_valid():
            save_datafile_add_form(schema.namespace, parentObject, request)

            success = True
        else:
            valid = False

    else:

        class DynamicForm(
                create_datafile_add_form(schema.namespace, parentObject)):
            pass

        form = DynamicForm()

    c = {
        'schema': schema,
        'form': form,
        'parameternames': parameternames,
        'type': otype,
        'success': success,
        'valid': valid,
        'parentObject': parentObject,
        'all_schema': all_schema,
        'schema_id': schema.id,
    }

    return HttpResponse(
        render_response_index(request, 'tardis_portal/ajax/parameteradd.html',
                              c))