mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Add number of missing final part marks to both spaces
This commit is contained in:
parent
8d34d3d564
commit
d0a6090553
12 changed files with 73 additions and 32 deletions
|
@ -41,9 +41,7 @@ assistantSpace = Admin(
|
|||
url="/assistant",
|
||||
endpoint="assistantSpace",
|
||||
template_mode="bootstrap3",
|
||||
index_view=customClasses.SecureAssistantIndexView(
|
||||
name="Assistant", template="assistant_index.html", url="/assistant", endpoint="assistantSpace"
|
||||
),
|
||||
index_view=customClasses.SecureAssistantIndexView(name="Assistant", url="/assistant", endpoint="assistantSpace"),
|
||||
)
|
||||
|
||||
from advlabdb import models
|
||||
|
|
|
@ -2,9 +2,10 @@ from flask import flash, redirect, request, url_for
|
|||
from flask_admin import AdminIndexView, BaseView, expose
|
||||
from flask_admin.contrib.sqla import ModelView
|
||||
from flask_security import current_user
|
||||
from sqlalchemy import and_
|
||||
|
||||
from advlabdb.exceptions import DataBaseException, ModelViewException
|
||||
from advlabdb.models import ExperimentMark, Part, PartStudent
|
||||
from advlabdb.models import ExperimentMark, Part, PartStudent, GroupExperiment, SemesterExperiment, Assistant
|
||||
from advlabdb.utils import reportBadAttempt, userActiveSemester
|
||||
|
||||
|
||||
|
@ -28,13 +29,20 @@ class SecureAdminIndexView(CustomIndexView):
|
|||
|
||||
@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,
|
||||
active_semester_experiment_marks_query = ExperimentMark.query.filter(
|
||||
ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester()))
|
||||
)
|
||||
|
||||
number_of_all_experiment_marks = active_semester_experiment_marks_query.count()
|
||||
|
||||
number_of_missing_final_experiment_marks = active_semester_experiment_marks_query.filter(
|
||||
ExperimentMark.final_experiment_mark == None
|
||||
).count()
|
||||
|
||||
return self.render(
|
||||
"admin_index.html", number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks
|
||||
"admin_index.html",
|
||||
number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks,
|
||||
number_of_all_experiment_marks=number_of_all_experiment_marks,
|
||||
)
|
||||
|
||||
|
||||
|
@ -42,6 +50,31 @@ class SecureAssistantIndexView(CustomIndexView):
|
|||
def is_accessible(self):
|
||||
return assistantViewIsAccessible()
|
||||
|
||||
@expose()
|
||||
def index(self):
|
||||
active_semester_experiment_marks_query = ExperimentMark.query.filter(
|
||||
ExperimentMark.group_experiment.has(
|
||||
GroupExperiment.semester_experiment.has(
|
||||
and_(
|
||||
SemesterExperiment.semester == userActiveSemester(),
|
||||
SemesterExperiment.assistants.any(Assistant.user == current_user),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
number_of_all_experiment_marks = active_semester_experiment_marks_query.count()
|
||||
|
||||
number_of_missing_final_experiment_marks = active_semester_experiment_marks_query.filter(
|
||||
ExperimentMark.final_experiment_mark == None
|
||||
).count()
|
||||
|
||||
return self.render(
|
||||
"assistant_index.html",
|
||||
number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks,
|
||||
number_of_all_experiment_marks=number_of_all_experiment_marks,
|
||||
)
|
||||
|
||||
|
||||
class CustomModelView(ModelView):
|
||||
create_modal = True
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
{% extends "admin/model/create.html" %}
|
||||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
||||
{{super()}}
|
||||
{{information(current_user, userActiveSemester, role="admin")}}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
|||
{% extends "admin/model/edit.html" %}
|
||||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
||||
{{super()}}
|
||||
{{information(current_user, userActiveSemester, role="admin")}}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
|
@ -1,11 +1,11 @@
|
|||
{% from "macros.html" import information %}
|
||||
{% from "macros.html" import information, missing_final_experiment_marks %}
|
||||
{% extends "admin/index.html" %}
|
||||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
||||
{{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>
|
||||
{{missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks)}}
|
||||
|
||||
{{super()}}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
|||
{% extends "admin/model/list.html" %}
|
||||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
||||
{{super()}}
|
||||
{{information(current_user, userActiveSemester, role="admin")}}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
|
@ -3,5 +3,5 @@
|
|||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="assistant") }}
|
||||
{{super()}}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
|||
{% extends "admin/model/edit.html" %}
|
||||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="assistant") }}
|
||||
{{super()}}
|
||||
{{information(current_user, userActiveSemester, role="assistant")}}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
|
@ -1,8 +1,11 @@
|
|||
{% from "macros.html" import information %}
|
||||
{% from "macros.html" import information, missing_final_experiment_marks %}
|
||||
{% extends "admin/index.html" %}
|
||||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="assistant") }}
|
||||
{{information(current_user, userActiveSemester, role="assistant")}}
|
||||
<h3>Welcome back!</h3>
|
||||
{{super()}}
|
||||
|
||||
{{missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks)}}
|
||||
|
||||
{{ super() }}
|
||||
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
|||
{% extends "admin/model/list.html" %}
|
||||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="assistant") }}
|
||||
{{super()}}
|
||||
{{information(current_user, userActiveSemester, role="assistant")}}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
|
@ -2,11 +2,11 @@
|
|||
{% extends "admin/master.html" %}
|
||||
|
||||
{% block body %}
|
||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
||||
{{information(current_user, userActiveSemester, role="admin")}}
|
||||
|
||||
{% for error in form.file.errors %}
|
||||
<div class="alert alert-danger">
|
||||
<strong>Error!</strong> {{error}}
|
||||
<strong>Error!</strong> {{ error }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
{% macro information(current_user, userActiveSemester, role) %}
|
||||
User: <a href="{{url_for('index')}}{{role}}/user/details/?id={{current_user.id}}">{{current_user.repr()}}</a>
|
||||
User: <a href="{{ url_for('index') }}{{ role }}/user/details/?id={{ current_user.id }}">{{ current_user.repr() }}</a>
|
||||
|
||||
| Active semester: {{userActiveSemester(flashWarning=True).repr()}}
|
||||
| Active semester: {{ userActiveSemester(flashWarning=True).repr() }}
|
||||
|
||||
{% if (role == "admin") and (current_user.has_role("assistant")) %}
|
||||
| <a href="{{url_for('index')}}assistant">Assistant space</a>.
|
||||
| <a href="{{ url_for('index') }}assistant">Assistant space</a>.
|
||||
{% elif (role == "assistant") and (current_user.has_role("admin")) %}
|
||||
| <a href="{{url_for('index')}}admin">Admin space</a>.
|
||||
| <a href="{{ url_for('index') }}admin">Admin space</a>.
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks) %}
|
||||
<p>
|
||||
Number of missing final experiment marks:
|
||||
{{ number_of_missing_final_experiment_marks }} / {{ number_of_all_experiment_marks }}
|
||||
</p>
|
||||
{% endmacro %}
|
Loading…
Reference in a new issue