def new_comp(): if request.method == 'GET': return render_template('edit-comp.html', **{'cform': CompetencyEditForm()}) else: f = CompetencyEditForm(request.form) if f.validate(): models.saveCompetency(f.toDict()) return redirect(url_for('competencies', uri=f.uri.data)) return render_template('edit-comp.html', **{'cform': f})
def edit_comp(objid): if request.method == 'GET': obj = models.getCompetencyById(objid) return_dict = {'cform': CompetencyEditForm(obj=obj)} else: f = CompetencyEditForm(request.form) valid = f.validate() if valid: models.updateCompetencyById(objid, f.toDict()) # redirect to comp details return redirect(url_for('competencies', uri=f.uri.data)) return_dict = {'cform': f} return render_template('edit-comp.html', **return_dict)