Exemple #1
0
def resource_action_edit(key, idr, ida):
    client = Client.query.filter_by(key=key).first()
    if not client:
        abort(404)
    if client.user != g.user:
        abort(403)
    resource = Resource.query.get(idr)
    if not resource:
        abort(404)
    action = ResourceAction.query.get(ida)
    if not action:
        abort(404)
    form = ResourceActionForm()
    form.edit_id = None
    form.edit_resource = resource
    if request.method == 'GET':
        form.name.data = action.name
        form.title.data = action.title
        form.description.data = action.description
    if form.validate_on_submit():
        form.populate_obj(action)
        db.session.commit()
        flash("Your action has been edited", "info")
        return render_redirect(url_for('client_info', key=key), code=303)
    return render_form(form=form, title="Edit action", formid="action_edit", submit="Save changes", ajax=True)
Exemple #2
0
def resource_action_edit(client, resource, action):
    form = ResourceActionForm(obj=action)
    form.edit_resource = resource
    if form.validate_on_submit():
        form.populate_obj(action)
        db.session.commit()
        flash("Your action has been edited", 'success')
        return render_redirect(url_for('client_info', key=client.key), code=303)
    return render_form(form=form, title="Edit action", formid="action_edit", submit="Save changes", ajax=True)
Exemple #3
0
def resource_action_new(client, resource):
    form = ResourceActionForm()
    form.edit_id = None
    form.edit_resource = resource
    if form.validate_on_submit():
        action = ResourceAction(resource=resource)
        form.populate_obj(action)
        db.session.add(action)
        db.session.commit()
        flash("Your new action has been saved", 'success')
        return render_redirect(url_for('client_info', key=client.key), code=303)
    return render_form(form=form, title="Define an action", formid="action_new", submit="Define action", ajax=True)
Exemple #4
0
def resource_action_edit(client, resource, action):
    form = ResourceActionForm(obj=action)
    form.edit_resource = resource
    if form.validate_on_submit():
        form.populate_obj(action)
        db.session.commit()
        flash("Your action has been edited", 'success')
        return render_redirect(url_for('client_info', key=client.key),
                               code=303)
    return render_form(form=form,
                       title="Edit action",
                       formid="action_edit",
                       submit="Save changes",
                       ajax=True)
Exemple #5
0
def resource_action_new(client, resource):
    form = ResourceActionForm()
    form.edit_id = None
    form.edit_resource = resource
    if form.validate_on_submit():
        action = ResourceAction(resource=resource)
        form.populate_obj(action)
        db.session.add(action)
        db.session.commit()
        flash("Your new action has been saved", 'success')
        return render_redirect(url_for('client_info', key=client.key),
                               code=303)
    return render_form(form=form,
                       title="Define an action",
                       formid="action_new",
                       submit="Define action",
                       ajax=True)
Exemple #6
0
def resource_action_new(key, idr):
    client = Client.query.filter_by(key=key).first_or_404()
    if not client.owner_is(g.user):
        abort(403)
    resource = Resource.query.get_or_404(idr)
    if resource.client != client:
        abort(403)
    form = ResourceActionForm()
    form.edit_id = None
    form.edit_resource = resource
    if form.validate_on_submit():
        action = ResourceAction(resource=resource)
        form.populate_obj(action)
        db.session.add(action)
        db.session.commit()
        flash("Your new action has been saved", "info")
        return render_redirect(url_for('client_info', key=key), code=303)
    return render_form(form=form, title="Define an action", formid="action_new", submit="Define action", ajax=True)