Example #1
0
def section_edit(name, section):
    space = ProposalSpace.query.filter_by(name=section).first()
    section  = ProposalSpaceSection.query.filter_by(name=section).first()
    form = SectionForm(obj=section)
    if form.validate_on_submit():
        form.populate_obj(section)
        db.session.commit()
        flash("Your section has been edited", 'info')
        return redirect(space.url_for('viewspace', name=space.name), code=303)
    return render_template('autoform.html', form=form, title="Edit section", submit="Save changes")
Example #2
0
def newsection(name):
    space = ProposalSpace.query.filter_by(name=name).first()
    if not space:
        abort(404)
    form = SectionForm()
    if form.validate_on_submit():
        section = ProposalSpaceSection(proposal_space=space)
        form.populate_obj(section)
        db.session.add(section)
        db.session.commit()
        flash("Your new section has been added", "info")
        return redirect(url_for('viewspace', name=space.name), code=303)
    return render_template('autoform.html', form=form, title="New section", submit="Create section")