mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Use kwargs with __init__
This commit is contained in:
parent
5704633d14
commit
aca41ede47
1 changed files with 10 additions and 15 deletions
|
@ -109,10 +109,10 @@ class PartStudent(db.Model):
|
||||||
f"Group's program {group.program} and student part's program {part.program} do not match!"
|
f"Group's program {group.program} and student part's program {part.program} do not match!"
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, student, part, group=None):
|
def __init__(self, part, group=None, **kwargs):
|
||||||
PartStudent.check(part, group)
|
PartStudent.check(part, group)
|
||||||
|
|
||||||
super().__init__(student=student, part=part, group=group)
|
super().__init__(part=part, group=group, **kwargs)
|
||||||
|
|
||||||
def checkThenSetFinalPartMark(self):
|
def checkThenSetFinalPartMark(self):
|
||||||
"""
|
"""
|
||||||
|
@ -274,10 +274,10 @@ class GroupExperiment(db.Model):
|
||||||
f"{student} has already done {semester_experiment.experiment} in {partStudent.part} and had {experimentMark}!"
|
f"{student} has already done {semester_experiment.experiment} in {partStudent.part} and had {experimentMark}!"
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, semester_experiment, group):
|
def __init__(self, semester_experiment, group, **kwargs):
|
||||||
GroupExperiment.check(semester_experiment, group)
|
GroupExperiment.check(semester_experiment, group)
|
||||||
|
|
||||||
super().__init__(semester_experiment=semester_experiment, group=group)
|
super().__init__(semester_experiment=semester_experiment, group=group, **kwargs)
|
||||||
|
|
||||||
for partStudent in group.part_students:
|
for partStudent in group.part_students:
|
||||||
db.session.add(ExperimentMark(part_student=partStudent, group_experiment=self))
|
db.session.add(ExperimentMark(part_student=partStudent, group_experiment=self))
|
||||||
|
@ -467,15 +467,10 @@ class Appointment(db.Model):
|
||||||
|
|
||||||
return assistant
|
return assistant
|
||||||
|
|
||||||
def __init__(self, date, special, group_experiment, assistant=None):
|
def __init__(self, group_experiment, assistant=None, **kwargs):
|
||||||
assistant = Appointment.checkAndGetAssistant(group_experiment, assistant)
|
assistant = Appointment.checkAndGetAssistant(group_experiment, assistant)
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(group_experiment=group_experiment, assistant=assistant, **kwargs)
|
||||||
date=date,
|
|
||||||
special=special,
|
|
||||||
group_experiment=group_experiment,
|
|
||||||
assistant=assistant,
|
|
||||||
)
|
|
||||||
|
|
||||||
def custom_update(self, date, special, group_experiment, assistant=None):
|
def custom_update(self, date, special, group_experiment, assistant=None):
|
||||||
self.assistant = Appointment.checkAndGetAssistant(group_experiment, assistant)
|
self.assistant = Appointment.checkAndGetAssistant(group_experiment, assistant)
|
||||||
|
@ -526,14 +521,14 @@ class Semester(db.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.str()
|
return self.str()
|
||||||
|
|
||||||
def __init__(self, label, year):
|
def __init__(self, label, year, **kwargs):
|
||||||
last_semester = Semester.lastSemester()
|
last_semester = Semester.lastSemester()
|
||||||
|
|
||||||
if last_semester is not None:
|
if last_semester is not None:
|
||||||
if year < last_semester.year or (year == last_semester.year and label == "SS"):
|
if year < last_semester.year or (year == last_semester.year and label == "SS"):
|
||||||
raise DatabaseException(f"You can only create semesters older than the last semester {last_semester}!")
|
raise DatabaseException(f"You can only create semesters older than the last semester {last_semester}!")
|
||||||
|
|
||||||
super().__init__(label=label, year=year)
|
super().__init__(label=label, year=year, **kwargs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def initFromOldSemester(label, year, oldSemester, transferParts, transferAssistants):
|
def initFromOldSemester(label, year, oldSemester, transferParts, transferAssistants):
|
||||||
|
@ -625,10 +620,10 @@ class ExperimentMark(db.Model):
|
||||||
if group_experiment not in part_student.group.group_experiments:
|
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("The group of the part student does not have the given group experiment!")
|
||||||
|
|
||||||
def __init__(self, part_student, group_experiment):
|
def __init__(self, part_student, group_experiment, **kwargs):
|
||||||
ExperimentMark.check(part_student, group_experiment)
|
ExperimentMark.check(part_student, group_experiment)
|
||||||
|
|
||||||
super().__init__(part_student=part_student, group_experiment=group_experiment)
|
super().__init__(part_student=part_student, group_experiment=group_experiment, **kwargs)
|
||||||
|
|
||||||
def update_final_experiment_mark(self):
|
def update_final_experiment_mark(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue