From d0e06d55e6c714adb6c4ccb184ad26227555777e Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Sun, 9 Feb 2025 11:03:47 +0100
Subject: [PATCH] =?UTF-8?q?Diplomy:=20Opraven=20p=C3=A1d=20p=C5=99i=20uplo?=
 =?UTF-8?q?adu=20obr=C3=A1zku=20b=C4=9Bhem=20zalo=C5=BEen=C3=AD=20sady=20d?=
 =?UTF-8?q?iplom=C5=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 mo/web/org_certs.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mo/web/org_certs.py b/mo/web/org_certs.py
index 8af0e0c9..21d3d5f9 100644
--- a/mo/web/org_certs.py
+++ b/mo/web/org_certs.py
@@ -176,6 +176,10 @@ def org_certificates(ct_id: int):
             form.populate_obj(cset)
             form.populate_obj(dparams)
             cset.design_params = dparams.to_json()
+            if new_cset:
+                # To je potřeba udělat už teď, protože cset.dir_path() níže potřebuje funkční relationships
+                sess.add(cset)
+                sess.flush()
             if dparams.background_type == BackgroundType.custom:
                 if form.upload_background.data:
                     old_background = cset.background_file
@@ -194,7 +198,6 @@ def org_certificates(ct_id: int):
                 cset.background_file = None
             changes = None
             if new_cset:
-                sess.add(cset)
                 mo.util.log(
                     type=db.LogType.cert_set,
                     what=contest.contest_id,
-- 
GitLab