mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-04 22:40:30 +00:00
Add assistant missing marks table to admin home page
This commit is contained in:
parent
b6e54ba0c0
commit
0f7700b11a
4 changed files with 50 additions and 33 deletions
|
@ -4,7 +4,7 @@ from flask_admin.contrib.sqla import ModelView
|
|||
from flask_admin.helpers import get_form_data
|
||||
from flask_admin.model.helpers import get_mdict_item_or_list
|
||||
from flask_login import current_user
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from .exceptions import DatabaseException, ModelViewException
|
||||
from .model_independent_funs import reportBadAttempt
|
||||
|
@ -48,22 +48,21 @@ class SecureAdminIndexView(CustomIndexView):
|
|||
|
||||
@expose("/")
|
||||
def index(self):
|
||||
active_semester_experiment_mark_ids_stmt = (
|
||||
select(ExperimentMark.final_experiment_mark)
|
||||
.join(PartStudent)
|
||||
.join(Part)
|
||||
.where(Part.semester == current_user.active_semester)
|
||||
)
|
||||
number_of_all_experiment_marks = get_count(active_semester_experiment_mark_ids_stmt)
|
||||
|
||||
number_of_missing_final_experiment_marks = get_count(
|
||||
active_semester_experiment_mark_ids_stmt.where(ExperimentMark.final_experiment_mark == None)
|
||||
assistants_num_missing = db.session.execute(
|
||||
select(Assistant, func.count())
|
||||
.join(Assistant.semester_experiments)
|
||||
.where(SemesterExperiment.semester == current_user.active_semester)
|
||||
.join(SemesterExperiment.group_experiments)
|
||||
.where(GroupExperiment.experiment_marks_missing == True)
|
||||
.join(GroupExperiment.experiment_marks)
|
||||
.where(ExperimentMark.final_experiment_mark == None)
|
||||
.group_by(Assistant.id)
|
||||
.order_by(func.count().desc())
|
||||
)
|
||||
|
||||
return self.render(
|
||||
"admin_index.jinja.html",
|
||||
number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks,
|
||||
number_of_all_experiment_marks=number_of_all_experiment_marks,
|
||||
assistants_num_missing=assistants_num_missing,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% from "macros.jinja.html" import information, missing_final_experiment_marks %}
|
||||
{% from "macros.jinja.html" import information %}
|
||||
{% extends "admin/index.html" %}
|
||||
|
||||
{% block body %}
|
||||
|
@ -6,7 +6,35 @@
|
|||
|
||||
<hr>
|
||||
|
||||
{{ missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks) }}
|
||||
<div class="d-inline-flex">
|
||||
<div class="table">
|
||||
<table class="table table-bordered">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th scope="col">
|
||||
Assistant
|
||||
</th>
|
||||
<th scope="col">
|
||||
Missing experiment marks
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for assistant_num_missing in assistants_num_missing %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ assistant_num_missing[0] }}
|
||||
</td>
|
||||
<td>
|
||||
{{ assistant_num_missing[1] }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ super() }}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% from "macros.jinja.html" import information, missing_final_experiment_marks %}
|
||||
{% from "macros.jinja.html" import information %}
|
||||
{% extends "admin/index.html" %}
|
||||
|
||||
{% block body %}
|
||||
|
@ -6,7 +6,10 @@
|
|||
|
||||
<hr>
|
||||
|
||||
{{ missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks)}}
|
||||
<p>
|
||||
Number of <strong>missing</strong> final experiment marks:
|
||||
{{ number_of_missing_final_experiment_marks }} / {{ number_of_all_experiment_marks }}
|
||||
</p>
|
||||
|
||||
{{ super() }}
|
||||
|
||||
|
|
|
@ -2,30 +2,17 @@
|
|||
User:
|
||||
<a
|
||||
href="{{ url_for('main.index') }}{{ role }}/user/edit/?id={{ current_user.id }}"
|
||||
>
|
||||
{{ current_user }}
|
||||
</a>
|
||||
>{{ current_user }}</a>
|
||||
| Active semester: {{ active_semester_str() }}
|
||||
{% if (role == "admin") and (current_user.has_role("assistant")) %}
|
||||
|
|
||||
<a
|
||||
href="{{ url_for('main.index') }}assistant"
|
||||
>
|
||||
Assistant space
|
||||
</a>.
|
||||
>Assistant space</a>.
|
||||
{% elif (role == "assistant") and (current_user.has_role("admin")) %}
|
||||
|
|
||||
<a
|
||||
href="{{ url_for('main.index') }}admin"
|
||||
>
|
||||
Admin space
|
||||
</a>.
|
||||
>Admin space</a>.
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks) %}
|
||||
<p>
|
||||
Number of <strong>missing</strong> final experiment marks:
|
||||
{{ number_of_missing_final_experiment_marks }} / {{ number_of_all_experiment_marks }}
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
|
Loading…
Reference in a new issue