Skip to content
Snippets Groups Projects
Commit 230aa365 authored by Jan Prachař's avatar Jan Prachař
Browse files

Import: V chybové hlášce rozlišovat chybu místa vs. oblasti

parent 3854ffcc
No related branches found
No related tags found
1 merge request!61Import: V chybové hlášce rozlišovat chybu místa vs. oblasti
...@@ -124,7 +124,7 @@ class Import: ...@@ -124,7 +124,7 @@ class Import:
rights = self.gatekeeper.rights_for(place, round.year, round.category, round.seq) rights = self.gatekeeper.rights_for(place, round.year, round.category, round.seq)
return rights.have_right(mo.rights.Right.manage_contest) return rights.have_right(mo.rights.Right.manage_contest)
def parse_opt_place(self, kod: str) -> Optional[db.Place]: def parse_opt_place(self, kod: str, what: str) -> Optional[db.Place]:
if kod == "": if kod == "":
return None return None
...@@ -133,7 +133,7 @@ class Import: ...@@ -133,7 +133,7 @@ class Import:
place = db.get_place_by_code(kod) place = db.get_place_by_code(kod)
if not place: if not place:
return self.error(f'Místo s kódem "{kod}" nenalezeno'+ return self.error(f'{what.title()} s kódem "{kod}" neexistuje'+
('. Nechybí vám # na začátku?' if re.fullmatch(r'\d+', kod) else '')) ('. Nechybí vám # na začátku?' if re.fullmatch(r'\d+', kod) else ''))
if not self.check_rights(place): if not self.check_rights(place):
...@@ -485,8 +485,8 @@ class ContestImport(Import): ...@@ -485,8 +485,8 @@ class ContestImport(Import):
school_place = self.parse_school(r.kod_skoly) school_place = self.parse_school(r.kod_skoly)
rocnik = self.parse_grade(r.rocnik, (school_place.school if school_place else None)) rocnik = self.parse_grade(r.rocnik, (school_place.school if school_place else None))
rok_naroz = self.parse_born(r.rok_naroz) rok_naroz = self.parse_born(r.rok_naroz)
misto = self.parse_opt_place(r.kod_mista) misto = self.parse_opt_place(r.kod_mista, 'místo')
oblast = self.parse_opt_place(r.kod_oblasti) oblast = self.parse_opt_place(r.kod_oblasti, 'oblast')
if (len(self.errors) > num_prev_errs if (len(self.errors) > num_prev_errs
or email is None or email is None
...@@ -541,7 +541,7 @@ class ProctorImport(Import): ...@@ -541,7 +541,7 @@ class ProctorImport(Import):
email = self.parse_email(r.email) email = self.parse_email(r.email)
krestni = self.parse_name(r.krestni) krestni = self.parse_name(r.krestni)
prijmeni = self.parse_name(r.prijmeni) prijmeni = self.parse_name(r.prijmeni)
misto = self.parse_opt_place(r.kod_mista) misto = self.parse_opt_place(r.kod_mista, 'místo')
if misto is None: if misto is None:
return self.error('Kód místa je povinné uvést') return self.error('Kód místa je povinné uvést')
...@@ -590,7 +590,7 @@ class JudgeImport(Import): ...@@ -590,7 +590,7 @@ class JudgeImport(Import):
email = self.parse_email(r.email) email = self.parse_email(r.email)
krestni = self.parse_name(r.krestni) krestni = self.parse_name(r.krestni)
prijmeni = self.parse_name(r.prijmeni) prijmeni = self.parse_name(r.prijmeni)
oblast = self.parse_opt_place(r.kod_oblasti) oblast = self.parse_opt_place(r.kod_oblasti, 'oblast')
if (len(self.errors) > num_prev_errs if (len(self.errors) > num_prev_errs
or email is None or email is None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment