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

Opraveno několik bugů okolo publikování výsledkovek

  - 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.
parent c744a314
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment