Skip to content
Snippets Groups Projects
Commit 8665f4b3 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Mazání registrace do ročníku

parent d2be5383
No related branches found
No related tags found
1 merge request!111Jk/delete registration
......@@ -572,6 +572,40 @@ class ParticipantEditForm(FlaskForm):
submit = wtforms.SubmitField("Uložit")
@app.route('/org/user/<int:user_id>/participant/<int:year>/delete', methods=('POST',))
def org_user_participant_delete(user_id: int, year: int):
sess = db.get_session()
user = mo.users.user_by_uid(user_id)
if not user:
raise werkzeug.exceptions.NotFound()
rr = g.gatekeeper.rights_generic()
if not rr.can_edit_user(user):
raise werkzeug.exceptions.Forbidden()
participant = sess.query(db.Participant).filter_by(user_id=user.user_id).filter_by(year=year).one_or_none()
if participant is None:
raise werkzeug.exceptions.NotFound()
if sess.query(db.Participation).filter_by(user_id=user.user_id).filter(db.Participation.contest.has(db.Contest.round.has(year=year))).count() != 0:
flash('Registraci není možná smazat, soutěžící se v daném ročníku účastní nějakého kola.', 'danger')
else:
sess.delete(participant)
app.logger.info(f"Participant id {user_id} year {year} deleted")
mo.util.log(
type=db.LogType.participant,
what=user_id,
details={'action': 'delete-participant', 'year': year, 'participant': db.row2dict(participant)},
)
sess.commit()
flash('Registrace smazána.', 'success')
return redirect(url_for('org_user', id=user_id))
@app.route('/org/user/<int:user_id>/participant/<int:year>/edit', methods=('GET', 'POST'))
def org_user_participant_edit(user_id: int, year: int):
sess = db.get_session()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment