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:
parent
cbda7e63ae
commit
8d34d3d564
5 changed files with 21 additions and 8 deletions
|
@ -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,
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ class AssistantUserView(SecureAssistantModelView):
|
|||
|
||||
|
||||
class AssistantDocsView(SecureAssistantBaseView):
|
||||
@expose("/", methods=["GET"])
|
||||
@expose()
|
||||
def index(self):
|
||||
return self.render("docs/assistant.html")
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -4,5 +4,8 @@
|
|||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
||||
<h3>Welcome back, commander!</h3>
|
||||
|
||||
<p>Number of missing final experiment marks: {{ number_of_missing_final_experiment_marks }}</p>
|
||||
|
||||
{{super()}}
|
||||
{% endblock %}
|
Loading…
Reference in a new issue