diff --git a/mo/jobs/score.py b/mo/jobs/score.py index 9cbcdb8c074973676703860f02f8b8120b575c2d..9399dce653214f082022c4f160c19690424821ed 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(