1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Check before updating experiment_marks_missing

This commit is contained in:
Mo 2022-06-30 17:53:46 +02:00
parent 7b9761d37b
commit 34c9b3318d
2 changed files with 12 additions and 6 deletions

View file

@ -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

View file

@ -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