mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-04 22:40:30 +00:00
Improve error messages
This commit is contained in:
parent
7d3717cb99
commit
293a73ede9
1 changed files with 10 additions and 6 deletions
|
@ -109,7 +109,7 @@ class PartStudent(db.Model):
|
|||
def check(part, group):
|
||||
if group is not None and group.program != part.program:
|
||||
raise DatabaseException(
|
||||
f"Group's program {group.program} and student part's program {part.program} do not match!"
|
||||
f"The group's program {group.program} and student part's program {part.program} don't match!"
|
||||
)
|
||||
|
||||
def __init__(self, part, group=None, **kwargs):
|
||||
|
@ -212,11 +212,13 @@ class Group(db.Model):
|
|||
commonProgram = part_students[0].part.program
|
||||
|
||||
if program and program != commonProgram:
|
||||
raise DatabaseException("Group's program and students' program mismatch!")
|
||||
raise DatabaseException(
|
||||
f"The group's program and students' program don't match for the part students {part_students}!"
|
||||
)
|
||||
|
||||
for partStudent in part_students[1:]:
|
||||
if partStudent.part.program != commonProgram:
|
||||
raise DatabaseException(f"Part Students {part_students} are not in the same program!")
|
||||
raise DatabaseException(f"The part students {part_students} are not in the same program!")
|
||||
|
||||
@staticmethod
|
||||
def customInit(part_students):
|
||||
|
@ -461,7 +463,7 @@ class Appointment(db.Model):
|
|||
assistant = semesterExperimentAssistants[0]
|
||||
else:
|
||||
raise DatabaseException(
|
||||
f"Experiment {semesterExperiment} has more than one assistant. You have to assign one of these assistants: {semesterExperimentAssistants}"
|
||||
f"The experiment {semesterExperiment} has more than one assistant. You have to assign one of these assistants: {semesterExperimentAssistants}"
|
||||
)
|
||||
|
||||
return assistant
|
||||
|
@ -651,10 +653,12 @@ class ExperimentMark(db.Model):
|
|||
@staticmethod
|
||||
def check(part_student, group_experiment):
|
||||
if not part_student.group:
|
||||
raise DatabaseException("The part student does not have a group yet!")
|
||||
raise DatabaseException(f"The part student {part_student} doesn't have a group yet!")
|
||||
|
||||
if group_experiment not in part_student.group.group_experiments:
|
||||
raise DatabaseException("The group of the part student does not have the given group experiment!")
|
||||
raise DatabaseException(
|
||||
f"The group {part_student.group} of the part student {part_student} doesn't have the given group experiment {group_experiment}!"
|
||||
)
|
||||
|
||||
def __init__(self, part_student, group_experiment, **kwargs):
|
||||
ExperimentMark.check(part_student, group_experiment)
|
||||
|
|
Loading…
Reference in a new issue