mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Remove ExperimentMark.customInit
This commit is contained in:
parent
2f7d005ea4
commit
2e6151d05f
2 changed files with 4 additions and 6 deletions
|
@ -1359,9 +1359,7 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def customCreateModel(self, form):
|
def customCreateModel(self, form):
|
||||||
return ExperimentMark.customInit(
|
return ExperimentMark(part_student=form.part_student.data, group_experiment=form.group_experiment.data)
|
||||||
part_student=form.part_student.data, group_experiment=form.group_experiment.data
|
|
||||||
)
|
|
||||||
|
|
||||||
def update_model(self, form, model):
|
def update_model(self, form, model):
|
||||||
if (form.oral_mark and form.oral_mark.data != model.oral_mark) or (
|
if (form.oral_mark and form.oral_mark.data != model.oral_mark) or (
|
||||||
|
|
|
@ -226,7 +226,7 @@ class GroupExperiment(db.Model):
|
||||||
super().__init__(semester_experiment=semester_experiment, group=group)
|
super().__init__(semester_experiment=semester_experiment, group=group)
|
||||||
|
|
||||||
for partStudent in group.part_students:
|
for partStudent in group.part_students:
|
||||||
db.session.add(ExperimentMark.customInit(part_student=partStudent, group_experiment=self))
|
db.session.add(ExperimentMark(part_student=partStudent, group_experiment=self))
|
||||||
|
|
||||||
def repr(self):
|
def repr(self):
|
||||||
return f"SemExp {self.semester_experiment.repr()}; Gr {self.group.repr()}"
|
return f"SemExp {self.semester_experiment.repr()}; Gr {self.group.repr()}"
|
||||||
|
@ -528,14 +528,14 @@ class ExperimentMark(db.Model):
|
||||||
|
|
||||||
__table_args__ = (db.UniqueConstraint(part_student_id, group_experiment_id),)
|
__table_args__ = (db.UniqueConstraint(part_student_id, group_experiment_id),)
|
||||||
|
|
||||||
def customInit(part_student, group_experiment):
|
def __init__(self, part_student, group_experiment):
|
||||||
if not part_student.group:
|
if not part_student.group:
|
||||||
raise DataBaseException("The part student does not have a group yet!")
|
raise DataBaseException("The part student does not have a group yet!")
|
||||||
else:
|
else:
|
||||||
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!")
|
||||||
|
|
||||||
return ExperimentMark(part_student=part_student, group_experiment=group_experiment)
|
super().__init__(part_student=part_student, group_experiment=group_experiment)
|
||||||
|
|
||||||
def updateFinalExperimentMark(self):
|
def updateFinalExperimentMark(self):
|
||||||
if None not in (self.oral_mark, self.protocol_mark):
|
if None not in (self.oral_mark, self.protocol_mark):
|
||||||
|
|
Loading…
Reference in a new issue