Skip to content
Snippets Groups Projects
Commit 059d65dc authored by Martin Mareš's avatar Martin Mareš
Browse files

Obezlička na neschopnost SQLAlchemy detekovat změny v JSONových sloupcích

parent a3f1ee9d
No related branches found
No related tags found
No related merge requests found
...@@ -40,17 +40,20 @@ def schedule_send_grading_info(round: db.Round, contests: Optional[List[db.Conte ...@@ -40,17 +40,20 @@ def schedule_send_grading_info(round: db.Round, contests: Optional[List[db.Conte
the_job = TheJob() the_job = TheJob()
job = the_job.create(db.JobType.send_grading_info, for_user) job = the_job.create(db.JobType.send_grading_info, for_user)
job.description = f'E-maily účastníkům {round.round_code_short()}' job.description = f'E-maily účastníkům {round.round_code_short()}'
job.in_json = { # XXX: SQLAlchemy neumí modifikovat obsah JSONových sloupců, jen celý obsah vyměnit za jiný.
# Proto slovník nejdřív připravíme, a teprve pak uložíme do job.in_json.
in_params = {
'round_id': round.round_id, 'round_id': round.round_id,
'contest_ids': None, 'contest_ids': None,
'new_state': new_state.name, 'new_state': new_state.name,
} }
if contests is not None: if contests is not None:
job.in_json['contest_ids'] = [c.contest_id for c in contests] in_params['contest_ids'] = [c.contest_id for c in contests]
if len(contests) == 1: if len(contests) == 1:
job.description += f' {contests[0].place.name_locative()}' job.description += f' {contests[0].place.name_locative()}'
else: else:
job.description += ' (' + inflect_number(len(contests), 'soutěž', 'soutěže', 'soutěží') + ')' job.description += ' (' + inflect_number(len(contests), 'soutěž', 'soutěže', 'soutěží') + ')'
job.in_json = in_params
the_job.submit() the_job.submit()
return True return True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment