예제 #1
0
def delete_field(id):
    field = JsonMethods.get_field(id)
    endpoint_id = int(field.get('endpoint_id'))
    response = JsonMethods.delete_field(id)
    if response.get('status') == 'error':
        flash(response.get('message'), 'danger')
    else:
        flash(response.get('message'), 'success')
    return redirect(url_for('views.detail_endpoint', id=endpoint_id))
예제 #2
0
def edit_field(id):
    form = EditFieldForm()
    field = JsonMethods.get_field(id)
    endpoint_id = int(field.get('endpoint_id'))
    if form.validate_on_submit():
        response = JsonMethods.edit_field(id,
                                          label=form.label.data,
                                          field_type=form.type.data,
                                          required=form.required.data,
                                          default=form.default.data,
                                          description=form.description.data)
        if response.get('status') == 'error':
            flash(response.get('message'), 'danger')
        else:
            flash(response.get('message'), 'success')
    else:
        flash(
            "The following errors occured while editing field #%s: %s" %
            (id, form.errors), 'danger')
    return redirect(url_for('views.detail_endpoint', id=endpoint_id))