Example #1
0
def _edit_service(method: str, server: ServiceSettings):
    form = ServiceSettingsForm(obj=server)

    if method == 'POST' and form.validate_on_submit():
        server = form.update_entry(server)
        server.save()
        return jsonify(status='ok'), 200

    return render_template('service/edit.html', form=form)
Example #2
0
    def add(self):
        model = ServiceSettings()
        form = ServiceSettingsForm(request.form, obj=model)
        if request.method == 'POST' and form.validate_on_submit():
            form.populate_obj(model)
            model = model.save()
            current_user.add_server(model)
            return jsonify(status='ok'), 200

        return render_template('service/add.html', form=form)