mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-04 22:40:30 +00:00
Fix crash on empty active_assistants
This commit is contained in:
parent
190c8bdba4
commit
91f0effd3a
2 changed files with 9 additions and 1 deletions
|
@ -1391,7 +1391,10 @@ class AnalysisView(SecureAdminBaseView):
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
if form.assistant_marks_submit.data:
|
if form.assistant_marks_submit.data:
|
||||||
return assistant_marks_analysis(self)
|
ret = assistant_marks_analysis(self)
|
||||||
|
|
||||||
|
if ret is not None:
|
||||||
|
return ret
|
||||||
|
|
||||||
if form.final_part_marks_submit.data:
|
if form.final_part_marks_submit.data:
|
||||||
return final_part_marks_analysis(self)
|
return final_part_marks_analysis(self)
|
||||||
|
|
|
@ -2,6 +2,7 @@ from base64 import b64encode
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from flask import flash
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
from matplotlib.ticker import MaxNLocator
|
from matplotlib.ticker import MaxNLocator
|
||||||
|
@ -78,6 +79,10 @@ def mark_hists(markType, active_assistants):
|
||||||
def assistant_marks_analysis(cls):
|
def assistant_marks_analysis(cls):
|
||||||
active_assistants = db.session.scalars(select(Assistant).join(User).where(User.active is True)).all()
|
active_assistants = db.session.scalars(select(Assistant).join(User).where(User.active is True)).all()
|
||||||
|
|
||||||
|
if not active_assistants:
|
||||||
|
flash("No active assistants!", "warning")
|
||||||
|
return None
|
||||||
|
|
||||||
oral_mark_hists = mark_hists("Oral", active_assistants)
|
oral_mark_hists = mark_hists("Oral", active_assistants)
|
||||||
protocol_mark_hists = mark_hists("Protocol", active_assistants)
|
protocol_mark_hists = mark_hists("Protocol", active_assistants)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue