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

Diplomy/sazba: Hledání standardního pozadí

parent 5fb038ea
No related branches found
No related tags found
1 merge request!137Sazba diplomů
......@@ -199,18 +199,32 @@ class CertMaker:
add_cert(db.CertType.honorary_mention, 'za úplné vyřešení úlohy', user.sort_key())
def prepare_files(self) -> None:
if self.design_params.background_type == BackgroundType.custom:
b = os.path.join(self.certs_dir, self.cset.background_file)
elif self.design_params.background_type == BackgroundType.standard:
b = os.path.join(mo.util.part_path('tex'), 'cert-background.pdf')
else:
b = None
if b:
if b := self._find_background():
background = os.path.join(self.job_dir, 'background.pdf')
mo.util.unlink_if_exists(background)
os.link(b, background)
def _find_background(self) -> Optional[str]:
bgt = self.design_params.background_type
if bgt == BackgroundType.custom:
return os.path.join(self.certs_dir, self.cset.background_file)
elif bgt == BackgroundType.blank:
return None
bg = bgt.name
candidates = [
f'{self.round.round_code()}/bg-{bg}.pdf',
f'bg-{bg}.pdf',
]
for cand in candidates:
bg = os.path.join(self.certs_dir, cand)
if os.path.isfile(bg):
return bg
raise RuntimeError("Nemohu najít standardní pozadí (kandidáti: " + " ".join(candidates) + ")")
def make_certs(self, cert_type: db.CertType) -> None:
certs = [cert for cert in self.certs if cert.type == cert_type]
if not certs:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment