From 059d65dca413c42eb0470c1843957bc2bf302268 Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Fri, 31 Jan 2025 16:26:17 +0100
Subject: [PATCH] =?UTF-8?q?Obezli=C4=8Dka=20na=20neschopnost=20SQLAlchemy?=
 =?UTF-8?q?=20detekovat=20zm=C4=9Bny=20v=20JSONov=C3=BDch=20sloupc=C3=ADch?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 mo/jobs/notify.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mo/jobs/notify.py b/mo/jobs/notify.py
index 0616855d..f32b9e09 100644
--- a/mo/jobs/notify.py
+++ b/mo/jobs/notify.py
@@ -40,17 +40,20 @@ def schedule_send_grading_info(round: db.Round, contests: Optional[List[db.Conte
     the_job = TheJob()
     job = the_job.create(db.JobType.send_grading_info, for_user)
     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,
         'contest_ids': None,
         'new_state': new_state.name,
     }
     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:
             job.description += f' {contests[0].place.name_locative()}'
         else:
             job.description += ' (' + inflect_number(len(contests), 'soutěž', 'soutěže', 'soutěží') + ')'
+    job.in_json = in_params
     the_job.submit()
     return True
 
-- 
GitLab