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

Add number of missing final experiment marks to admin

This commit is contained in:
Mo 2022-02-24 00:08:14 +01:00
parent cbda7e63ae
commit 8d34d3d564
5 changed files with 21 additions and 8 deletions

View file

@ -33,9 +33,7 @@ adminSpace = Admin(
url="/admin", url="/admin",
endpoint="adminSpace", endpoint="adminSpace",
template_mode="bootstrap3", template_mode="bootstrap3",
index_view=customClasses.SecureAdminIndexView( index_view=customClasses.SecureAdminIndexView(name="Admin", url="/admin", endpoint="adminSpace"),
name="Admin", template="admin_index.html", url="/admin", endpoint="adminSpace"
),
) )
assistantSpace = Admin( assistantSpace = Admin(
app, app,

View file

@ -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.", 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): def index(self):
form = ImportView.FileForm() form = ImportView.FileForm()
@ -950,7 +950,7 @@ class ImportView(SecureAdminBaseView):
class DocsView(SecureAdminBaseView): class DocsView(SecureAdminBaseView):
@expose("/", methods=["GET"]) @expose()
def index(self): def index(self):
return self.render("docs/admin.html") return self.render("docs/admin.html")

View file

@ -172,7 +172,7 @@ class AssistantUserView(SecureAssistantModelView):
class AssistantDocsView(SecureAssistantBaseView): class AssistantDocsView(SecureAssistantBaseView):
@expose("/", methods=["GET"]) @expose()
def index(self): def index(self):
return self.render("docs/assistant.html") return self.render("docs/assistant.html")

View file

@ -1,10 +1,11 @@
from flask import flash, redirect, request, url_for 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_admin.contrib.sqla import ModelView
from flask_security import current_user from flask_security import current_user
from advlabdb.exceptions import DataBaseException, ModelViewException 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(): def adminViewIsAccessible():
@ -25,6 +26,17 @@ class SecureAdminIndexView(CustomIndexView):
def is_accessible(self): def is_accessible(self):
return adminViewIsAccessible() 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): class SecureAssistantIndexView(CustomIndexView):
def is_accessible(self): def is_accessible(self):

View file

@ -4,5 +4,8 @@
{% block body %} {% block body %}
{{ information(current_user, userActiveSemester, role="admin") }} {{ information(current_user, userActiveSemester, role="admin") }}
<h3>Welcome back, commander!</h3> <h3>Welcome back, commander!</h3>
<p>Number of missing final experiment marks: {{ number_of_missing_final_experiment_marks }}</p>
{{super()}} {{super()}}
{% endblock %} {% endblock %}