mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +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",
|
url="/assistant",
|
||||||
endpoint="assistantSpace",
|
endpoint="assistantSpace",
|
||||||
template_mode="bootstrap3",
|
template_mode="bootstrap3",
|
||||||
index_view=customClasses.SecureAssistantIndexView(
|
index_view=customClasses.SecureAssistantIndexView(name="Assistant", url="/assistant", endpoint="assistantSpace"),
|
||||||
name="Assistant", template="assistant_index.html", url="/assistant", endpoint="assistantSpace"
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from advlabdb import models
|
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 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 sqlalchemy import and_
|
||||||
|
|
||||||
from advlabdb.exceptions import DataBaseException, ModelViewException
|
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
|
from advlabdb.utils import reportBadAttempt, userActiveSemester
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,13 +29,20 @@ class SecureAdminIndexView(CustomIndexView):
|
||||||
|
|
||||||
@expose()
|
@expose()
|
||||||
def index(self):
|
def index(self):
|
||||||
number_of_missing_final_experiment_marks = ExperimentMark.query.filter(
|
active_semester_experiment_marks_query = ExperimentMark.query.filter(
|
||||||
ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester())),
|
ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester()))
|
||||||
ExperimentMark.final_experiment_mark == None,
|
)
|
||||||
|
|
||||||
|
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()
|
).count()
|
||||||
|
|
||||||
return self.render(
|
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):
|
def is_accessible(self):
|
||||||
return assistantViewIsAccessible()
|
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):
|
class CustomModelView(ModelView):
|
||||||
create_modal = True
|
create_modal = True
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
{% extends "admin/model/create.html" %}
|
{% extends "admin/model/create.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
{{information(current_user, userActiveSemester, role="admin")}}
|
||||||
{{super()}}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
||||||
{% extends "admin/model/edit.html" %}
|
{% extends "admin/model/edit.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
{{information(current_user, userActiveSemester, role="admin")}}
|
||||||
{{super()}}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,11 +1,11 @@
|
||||||
{% from "macros.html" import information %}
|
{% from "macros.html" import information, missing_final_experiment_marks %}
|
||||||
{% extends "admin/index.html" %}
|
{% extends "admin/index.html" %}
|
||||||
|
|
||||||
{% 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>
|
{{missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks)}}
|
||||||
|
|
||||||
{{super()}}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
||||||
{% extends "admin/model/list.html" %}
|
{% extends "admin/model/list.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
{{information(current_user, userActiveSemester, role="admin")}}
|
||||||
{{super()}}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -3,5 +3,5 @@
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ information(current_user, userActiveSemester, role="assistant") }}
|
{{ information(current_user, userActiveSemester, role="assistant") }}
|
||||||
{{super()}}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
||||||
{% extends "admin/model/edit.html" %}
|
{% extends "admin/model/edit.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ information(current_user, userActiveSemester, role="assistant") }}
|
{{information(current_user, userActiveSemester, role="assistant")}}
|
||||||
{{super()}}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,8 +1,11 @@
|
||||||
{% from "macros.html" import information %}
|
{% from "macros.html" import information, missing_final_experiment_marks %}
|
||||||
{% extends "admin/index.html" %}
|
{% extends "admin/index.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ information(current_user, userActiveSemester, role="assistant") }}
|
{{information(current_user, userActiveSemester, role="assistant")}}
|
||||||
<h3>Welcome back!</h3>
|
<h3>Welcome back!</h3>
|
||||||
{{super()}}
|
|
||||||
|
{{missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks)}}
|
||||||
|
|
||||||
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
||||||
{% extends "admin/model/list.html" %}
|
{% extends "admin/model/list.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ information(current_user, userActiveSemester, role="assistant") }}
|
{{information(current_user, userActiveSemester, role="assistant")}}
|
||||||
{{super()}}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -2,11 +2,11 @@
|
||||||
{% extends "admin/master.html" %}
|
{% extends "admin/master.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ information(current_user, userActiveSemester, role="admin") }}
|
{{information(current_user, userActiveSemester, role="admin")}}
|
||||||
|
|
||||||
{% for error in form.file.errors %}
|
{% for error in form.file.errors %}
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<strong>Error!</strong> {{error}}
|
<strong>Error!</strong> {{ error }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
{% macro information(current_user, userActiveSemester, role) %}
|
{% 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")) %}
|
{% 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")) %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% 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