Skip to content
Snippets Groups Projects

Nastavení kol a úloh

Merged Jiří Setnička requested to merge jirka/manage_round into devel
1 unresolved thread
1 file
+ 23
4
Compare changes
  • Side-by-side
  • Inline
+ 23
4
@@ -64,9 +64,9 @@ class ParticipantsActionForm(FlaskForm):
def do_action(self, round: db.Round, rights: mo.rights.Rights, query: Query) -> bool:
"""Do participation modification on partipations from given query
(possibly filtered by checkboxes). Expects that rights for round/contest
are checked before calling this function, `rights` param are used only
for checking that we can move participation to another contest."""
(possibly filtered by checkboxes). `rights` param is used to check rights
for contest of each modified participation or for contest in which
participation is moved to."""
if not self.validate_on_submit():
return False
@@ -93,6 +93,7 @@ class ParticipantsActionForm(FlaskForm):
rights.get_for_contest(contest)
if not rights.have_right(mo.rights.Right.manage_contest):
flash(f"Nemáte právo ke správě soutěže v kole {round.round_code()} v oblasti {contest_place.name}, nelze do ní přesunout účastníky", 'danger')
return False
elif self.remove_participation.data:
pass
else:
@@ -105,8 +106,26 @@ class ParticipantsActionForm(FlaskForm):
flash('Data v checkboxech nelze převést na čísla, kontaktujte správce', 'danger')
return False
count = 0
# Check all participations if we can edit them
ctants = query.all()
rights_cache = set()
for pion, _, _ in ctants:
u = pion.user
if self.action_on.data == 'checked' and u.user_id not in user_ids:
continue
if pion.contest_id in rights_cache:
continue
rights.get_for_contest(pion.contest)
if rights.have_right(mo.rights.Right.manage_contest):
rights_cache.add(pion.contest_id)
continue
flash(
f"Nemáte právo ke správě soutěže v kole {round.round_code()} v oblasti {pion.contest.place.name} "
+ f"(účastník {u.first_name} {u.last_name}). Žádná akce nebyla provedena.", 'danger'
)
return False
count = 0
for pion, _, _ in ctants:
u = pion.user
if self.action_on.data == 'checked' and u.user_id not in user_ids:
Loading