def edit_team(team): team = Team.by_id(team) if team is None: flash('Team does not exists') return redirect(url_for('frontend.admin')) person_one = team.persons[0] person_two = team.persons[1] team_data = { 'team': team.name, 'person_one': person_one.raw_name, 'person_two': person_two.raw_name, 'email_one': person_one.email_address, 'email_two': person_two.email_address, 'payed': team.payed } form = EditForm(request.form, data=team_data) if form.validate_on_submit(): err = team.update_from_from(form) if err: form._errors = err form.team.errors = err['team'] return render_template('edit_team.html', team=team, edit_form=form) return redirect(url_for('frontend.admin')) return render_template('edit_team.html', team=team, edit_form=form)
def delete_team(team_id): team = Team.by_id(team_id) if team: db.session.delete(team) db.session.commit() return redirect(url_for('frontend.admin'))