From 4a83ffdabc1ddabe17c48cbb5cb6674a291b8cee Mon Sep 17 00:00:00 2001 From: Mo8it Date: Sat, 21 Aug 2021 23:08:32 +0200 Subject: [PATCH] Added final part mark calculation to assistantSpace --- advlabdb/assistantModelViews.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/advlabdb/assistantModelViews.py b/advlabdb/assistantModelViews.py index 7ee48c5..c4a217f 100644 --- a/advlabdb/assistantModelViews.py +++ b/advlabdb/assistantModelViews.py @@ -118,16 +118,20 @@ class AssistantExperimentMarkView(SecureAssistantModelView): ) ) - def after_model_change(self, form, model, is_created): - if model.oral_mark or model.protocol_mark: - try: - model.assistant = current_user.assistant + def update_model(self, form, model): + if (form.oral_mark and form.oral_mark.data != model.oral_mark) or ( + form.protocol_mark and form.protocol_mark.data != model.protocol_mark + ): + model.assistant = current_user.assistant - self.session.commit() - except Exception as ex: - flash(str(ex), "error") + ret = super().update_model(form, model) - self.session.rollback() + model.part_student.checkThenSetFinalPartMark() + + return ret + else: + # Nothing changed + return True assistantSpace.add_view(