Esempio n. 1
0
 def post(self, _id):
     template = get_object_or_404(Template, Template.id == _id)
     form = TemplateForm(template)
     if form.validate_on_submit():
         template.name = request.form.get('name')
         template.description = request.form.get('description')
         db.session.commit()
         return redirect(url_for('admin.edit_template', _id=template.id))
     return render_template("template/template.html", form=form)
Esempio n. 2
0
 def post(self):
     form = TemplateForm()
     if form.validate_on_submit():
         template = Template(name=form.name.data,
                             description=form.description.data)
         db.session.add(template)
         db.session.commit()
         return redirect(url_for('admin.edit_template', _id=template.id))
     return render_template("template/template.html", form=form)