Пример #1
0
def load_agent_scripts(app, db):
    if not db.engine.has_table("agent_script"):
        return

    from app.models import AgentScript

    app.agent_scripts = AgentScript.get_scripts_string()
Пример #2
0
def delete_script(name):
    deleteForm = forms.DeleteForm()

    if deleteForm.validate_on_submit():
        delScript = AgentScript.query.filter_by(name=name).first()
        if delScript:
            db.session.delete(delScript)
            db.session.commit()
            current_app.agent_scripts = AgentScript.get_scripts_string()
            flash(f"{name} successfully deleted.", "success")
        else:
            flash(f"{name} doesn't exist!", "danger")
        return redirect(url_for("admin.agent_config"))
Пример #3
0
def add_script():
    addScriptForm = forms.AddScriptForm(prefix="add-script")

    if addScriptForm.validate_on_submit():
        newscript = AgentScript(name=addScriptForm.scriptName.data)
        db.session.add(newscript)
        db.session.commit()
        current_app.agent_scripts = AgentScript.get_scripts_string()
        flash(f"{newscript.name} successfully added to scripts", "success")
    else:
        flash(f"{addScriptForm.scriptName.data} couldn't be added to scripts",
              "danger")

    return redirect(url_for("admin.agent_config"))