def newspace(): form = ProposalSpaceForm() if form.validate_on_submit(): space = ProposalSpace(user=g.user) form.populate_obj(space) space.description_html = markdown(space.description) db.session.add(space) db.session.commit() flash("Your new space has been created", "info") return redirect(url_for('viewspace', name=space.name), code=303) return render_template('autoform.html', form=form, title="Create a new proposal space", submit="Create space")
def editspace(name): space = ProposalSpace.query.filter_by(name=name).first() if not space: abort(404) form = ProposalSpaceForm(obj=space) if form.validate_on_submit(): form.populate_obj(space) space.description_html = markdown(space.description) db.session.commit() flash("Your changes have been saved", "info") return redirect(url_for('viewspace', name=space.name), code=303) return render_template('autoform.html', form=form, title="Edit proposal space", submit="Save changes")