diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index 2009534..f0d7c1b 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -1161,14 +1161,16 @@ class ExperimentMarkView(SecureAdminModelView): return ExperimentMark(part_student=form.part_student.data, group_experiment=form.group_experiment.data) def update_model(self, form, model): - if (form.oral_mark is not None and form.oral_mark.data != model.oral_mark) or ( - form.protocol_mark is not None and form.protocol_mark.data != model.protocol_mark - ): + if (form.oral_mark.data != model.oral_mark) or (form.protocol_mark.data != model.protocol_mark): model.admin = current_user.admin updateSuccessful = super().update_model(form, model) - model.part_student.checkThenSetFinalPartMark() + if updateSuccessful: + final_part_mark_changed = model.part_student.checkThenSetFinalPartMark() + + if final_part_mark_changed: + model.group_experiment.update_experiment_marks_missing() return updateSuccessful diff --git a/advlabdb/assistantModelViews.py b/advlabdb/assistantModelViews.py index 00c9fe7..8bf01e0 100644 --- a/advlabdb/assistantModelViews.py +++ b/advlabdb/assistantModelViews.py @@ -135,6 +135,7 @@ class AssistantGroupExperimentView(SecureAssistantModelView): ] if form.validate_on_submit(): + any_final_part_mark_changed = False try: for ind, appointment in enumerate(appointments): appointment.date = appointment_fields[ind].data @@ -152,9 +153,12 @@ class AssistantGroupExperimentView(SecureAssistantModelView): experiment_mark.assistant = current_user.assistant - experiment_mark.part_student.checkThenSetFinalPartMark() + final_part_mark_changed = experiment_mark.part_student.checkThenSetFinalPartMark() + if final_part_mark_changed: + any_final_part_mark_changed = True - group_experiment.update_experiment_marks_missing() + if any_final_part_mark_changed: + group_experiment.update_experiment_marks_missing() group_experiment.note = form.note.data