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

Diplomy/sazba: Předáváme i ID výsledkové listiny, podle které vydávat

parent 5c5dcdb0
Branches
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ import mo.util_format ...@@ -19,7 +19,7 @@ import mo.util_format
from mo.util_tex import tex_arg, tex_key, run_tex, format_hacks, QREncoder from mo.util_tex import tex_arg, tex_key, run_tex, format_hacks, QREncoder
def schedule_create_certs(contest: db.Contest, for_user: db.User) -> int: def schedule_create_certs(contest: db.Contest, scoretable_id: Optional[int], for_user: db.User) -> int:
place = contest.place place = contest.place
the_job = TheJob() the_job = TheJob()
...@@ -27,6 +27,7 @@ def schedule_create_certs(contest: db.Contest, for_user: db.User) -> int: ...@@ -27,6 +27,7 @@ def schedule_create_certs(contest: db.Contest, for_user: db.User) -> int:
job.description = f'Diplomy {contest.round.round_code()} {place.name_locative()}' job.description = f'Diplomy {contest.round.round_code()} {place.name_locative()}'
job.in_json = { job.in_json = {
'contest_id': contest.contest_id, 'contest_id': contest.contest_id,
'scoretable_id': scoretable_id,
} }
the_job.submit() the_job.submit()
assert the_job.job_id is not None assert the_job.job_id is not None
...@@ -141,18 +142,27 @@ class CertMaker: ...@@ -141,18 +142,27 @@ class CertMaker:
walker = Walker(self.job.in_json) walker = Walker(self.job.in_json)
with walker.enter_object() as root: with walker.enter_object() as root:
self.contest_id = root['contest_id'].as_int() self.contest_id = root['contest_id'].as_int()
if root['scoretable_id'].is_null():
scoretable_id = None
else:
scoretable_id = root['scoretable_id'].as_int()
sess = db.get_session() sess = db.get_session()
self.contest = (sess.query(db.Contest) self.contest = (sess.query(db.Contest)
.options(joinedload(db.Contest.round)) .options(joinedload(db.Contest.round))
.options(joinedload(db.Contest.place)) .options(joinedload(db.Contest.place))
.options(joinedload(db.Contest.scoretable))
.get(self.contest_id) .get(self.contest_id)
) )
assert self.contest is not None assert self.contest is not None
self.round = self.contest.round self.round = self.contest.round
self.place = self.contest.place self.place = self.contest.place
self.scoretable = self.contest.scoretable logger.info(f'{self.the_job.log_prefix} Vytvářím certifikáty pro soutěž #{self.contest.contest_id} s výsledkovou listinou #{scoretable_id}')
if scoretable_id is not None:
self.scoretable = sess.query(db.ScoreTable).get(scoretable_id)
assert self.scoretable is not None
else:
self.scoretable = None
self.cset = sess.query(db.CertSet).get(self.contest_id) self.cset = sess.query(db.CertSet).get(self.contest_id)
assert self.cset is not None assert self.cset is not None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment