diff --git a/advlabdb/__init__.py b/advlabdb/__init__.py index 3acc2b9..1486bca 100644 --- a/advlabdb/__init__.py +++ b/advlabdb/__init__.py @@ -33,9 +33,7 @@ adminSpace = Admin( url="/admin", endpoint="adminSpace", template_mode="bootstrap3", - index_view=customClasses.SecureAdminIndexView( - name="Admin", template="admin_index.html", url="/admin", endpoint="adminSpace" - ), + index_view=customClasses.SecureAdminIndexView(name="Admin", url="/admin", endpoint="adminSpace"), ) assistantSpace = Admin( app, diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index 424e982..9c1c36c 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -925,7 +925,7 @@ class ImportView(SecureAdminBaseView): description="The import file has to be a text file (with .txt at the end) encoded in UTF-8. It has to strictly follow the required format.", ) - @expose("/", methods=["GET", "POST"]) + @expose(methods=("GET", "POST")) def index(self): form = ImportView.FileForm() @@ -950,7 +950,7 @@ class ImportView(SecureAdminBaseView): class DocsView(SecureAdminBaseView): - @expose("/", methods=["GET"]) + @expose() def index(self): return self.render("docs/admin.html") diff --git a/advlabdb/assistantModelViews.py b/advlabdb/assistantModelViews.py index 52cca84..f66e8ca 100644 --- a/advlabdb/assistantModelViews.py +++ b/advlabdb/assistantModelViews.py @@ -172,7 +172,7 @@ class AssistantUserView(SecureAssistantModelView): class AssistantDocsView(SecureAssistantBaseView): - @expose("/", methods=["GET"]) + @expose() def index(self): return self.render("docs/assistant.html") diff --git a/advlabdb/customClasses.py b/advlabdb/customClasses.py index 09f4ea9..0d505d0 100644 --- a/advlabdb/customClasses.py +++ b/advlabdb/customClasses.py @@ -1,10 +1,11 @@ from flask import flash, redirect, request, url_for -from flask_admin import AdminIndexView, BaseView +from flask_admin import AdminIndexView, BaseView, expose from flask_admin.contrib.sqla import ModelView from flask_security import current_user from advlabdb.exceptions import DataBaseException, ModelViewException -from advlabdb.utils import reportBadAttempt +from advlabdb.models import ExperimentMark, Part, PartStudent +from advlabdb.utils import reportBadAttempt, userActiveSemester def adminViewIsAccessible(): @@ -25,6 +26,17 @@ class SecureAdminIndexView(CustomIndexView): def is_accessible(self): return adminViewIsAccessible() + @expose() + def index(self): + number_of_missing_final_experiment_marks = ExperimentMark.query.filter( + ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester())), + ExperimentMark.final_experiment_mark == None, + ).count() + + return self.render( + "admin_index.html", number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks + ) + class SecureAssistantIndexView(CustomIndexView): def is_accessible(self): diff --git a/advlabdb/templates/admin_index.html b/advlabdb/templates/admin_index.html index e650c14..8c10c37 100644 --- a/advlabdb/templates/admin_index.html +++ b/advlabdb/templates/admin_index.html @@ -4,5 +4,8 @@ {% block body %} {{ information(current_user, userActiveSemester, role="admin") }}

Welcome back, commander!

+ +

Number of missing final experiment marks: {{ number_of_missing_final_experiment_marks }}

+ {{super()}} {% endblock %} \ No newline at end of file