From d68477af997a1917f14deebfc839ea31bdd4b5d8 Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Wed, 5 Feb 2025 15:30:25 +0100 Subject: [PATCH] =?UTF-8?q?Opraveno=20n=C4=9Bkolik=20bug=C5=AF=20okolo=20p?= =?UTF-8?q?ublikov=C3=A1n=C3=AD=20v=C3=BDsledkovek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Job se neplánuje, pokud má kolo vypnuté publikování. - Když během jobu zjistíme, že už má kolo vypnuté publikování, a job kvůli tomu ukončíme, nastavíme informativní hlášku. - Při odpublikování nespadneme, pokud v konfiguraci není MO_WEB_SERVER. Closes #436. --- mo/jobs/score.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/mo/jobs/score.py b/mo/jobs/score.py index 9cbcdb8c..9399dce6 100644 --- a/mo/jobs/score.py +++ b/mo/jobs/score.py @@ -262,6 +262,9 @@ def api_params(contest: db.Contest) -> Dict[str, Any]: def schedule_export_score_to_mo_web(contest: db.Contest, score_table: db.ScoreTable) -> None: + if not contest.round.export_score_to_mo_web: + return + if not hasattr(config, 'MO_WEB_SERVER'): logger.warning('Export výsledkové listiny na web není nakonfigurován') return @@ -319,7 +322,7 @@ def get_web_json(score_table: db.ScoreTable, contest: db.Contest): @job_handler(db.JobType.export_score_to_mo_web) -def handle_export_score_to_mo_web(the_job: TheJob): +def handle_export_score_to_mo_web(the_job: TheJob) -> None: API_ENDPOINT_JSON = "/Redakce/Api/ScoreboardImporterApi/RawData" API_ENDPOINT_PDF = "/Redakce/Api/ScoreboardImporterApi/PdfData" @@ -332,7 +335,8 @@ def handle_export_score_to_mo_web(the_job: TheJob): round = contest.round if not round.export_score_to_mo_web: - return None + job.result = 'Kolo již nemá povolený export na web' + return def error(err_text: str, data_format: str, more_details={}): mo.util.log( @@ -429,6 +433,13 @@ def handle_export_score_to_mo_web(the_job: TheJob): def schedule_revert_export_score_to_mo_web(contest: db.Contest) -> None: + if not contest.round.export_score_to_mo_web: + return + + if not hasattr(config, 'MO_WEB_SERVER'): + logger.warning('Export výsledkové listiny na web není nakonfigurován') + return + the_job = TheJob() job = the_job.create(db.JobType.revert_export_score_to_mo_web, db.get_system_user(), priority=1) job.description = f'Zrušení publikování výsledkové listiny {contest.round.round_code_short()} {contest.place.name_locative()} na webu MO' @@ -437,7 +448,7 @@ def schedule_revert_export_score_to_mo_web(contest: db.Contest) -> None: @job_handler(db.JobType.revert_export_score_to_mo_web) -def handle_revert_export_score_to_mo_web(the_job: TheJob): +def handle_revert_export_score_to_mo_web(the_job: TheJob) -> None: API_ENDPOINT_DELETE = "/Redakce/Api/ScoreboardImporterApi/Delete" job = mo.util.assert_not_none(the_job.job) @@ -448,7 +459,8 @@ def handle_revert_export_score_to_mo_web(the_job: TheJob): round = contest.round if not round.export_score_to_mo_web: - return None + job.result = 'Kolo již nemá povolený export na web' + return def error(err_text: str, more_details={}): mo.util.log( -- GitLab