diff --git a/advlabdb/model_dependent_funs.py b/advlabdb/model_dependent_funs.py
index ff49cc0..46f904a 100644
--- a/advlabdb/model_dependent_funs.py
+++ b/advlabdb/model_dependent_funs.py
@@ -67,3 +67,12 @@ def reportBadAttempt(message):
def get_count(table):
return db.session.scalar(select(func.count()).select_from(table))
+
+
+def active_semester_repr():
+ active_semester = current_user.active_semester
+ repr = active_semester.repr()
+ if active_semester != lastSemester():
+ flash(f"You are in the old semester {repr}!", "warning")
+
+ return repr
diff --git a/advlabdb/routes.py b/advlabdb/routes.py
index c506978..c4cb308 100644
--- a/advlabdb/routes.py
+++ b/advlabdb/routes.py
@@ -2,17 +2,17 @@ from flask import flash, redirect, render_template, request, url_for
from flask_security import auth_required, current_user, roles_accepted, roles_required
from . import app, db
-from .model_dependent_funs import lastSemester, setUserActiveSemester
+from .model_dependent_funs import (
+ active_semester_repr,
+ lastSemester,
+ setUserActiveSemester,
+)
from .models import Semester
@app.context_processor
def util_processor():
- active_semester = current_user.active_semester
- if active_semester != lastSemester():
- flash(f"You are in the old semester {current_user.active_semester.repr()}!", "warning")
-
- return dict(active_semester=active_semester, current_user=current_user)
+ return dict(active_semester_repr=active_semester_repr, current_user=current_user)
@app.route("/")
diff --git a/advlabdb/templates/actions.html b/advlabdb/templates/actions.html
index 549cccb..a430add 100644
--- a/advlabdb/templates/actions.html
+++ b/advlabdb/templates/actions.html
@@ -2,7 +2,7 @@
{% extends "admin/master.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
diff --git a/advlabdb/templates/admin_create.html b/advlabdb/templates/admin_create.html
index 0e6dd50..83de68c 100644
--- a/advlabdb/templates/admin_create.html
+++ b/advlabdb/templates/admin_create.html
@@ -2,6 +2,6 @@
{% extends "admin/model/create.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
{{ super() }}
{% endblock %}
diff --git a/advlabdb/templates/admin_details.html b/advlabdb/templates/admin_details.html
index f89e673..7c5e7a5 100644
--- a/advlabdb/templates/admin_details.html
+++ b/advlabdb/templates/admin_details.html
@@ -2,6 +2,6 @@
{% extends "admin/model/details.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
{{ super() }}
{% endblock %}
diff --git a/advlabdb/templates/admin_edit.html b/advlabdb/templates/admin_edit.html
index b0314d4..cc7909d 100644
--- a/advlabdb/templates/admin_edit.html
+++ b/advlabdb/templates/admin_edit.html
@@ -2,6 +2,6 @@
{% extends "admin/model/edit.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
{{ super() }}
{% endblock %}
diff --git a/advlabdb/templates/admin_index.html b/advlabdb/templates/admin_index.html
index f5accb6..b6405fa 100644
--- a/advlabdb/templates/admin_index.html
+++ b/advlabdb/templates/admin_index.html
@@ -2,7 +2,7 @@
{% extends "admin/index.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
diff --git a/advlabdb/templates/admin_list.html b/advlabdb/templates/admin_list.html
index a0f9662..6c4b324 100644
--- a/advlabdb/templates/admin_list.html
+++ b/advlabdb/templates/admin_list.html
@@ -2,6 +2,6 @@
{% extends "admin/model/list.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
{{ super() }}
{% endblock %}
diff --git a/advlabdb/templates/analysis/analysis.html b/advlabdb/templates/analysis/analysis.html
index 8ba4ff5..bf4d8a5 100644
--- a/advlabdb/templates/analysis/analysis.html
+++ b/advlabdb/templates/analysis/analysis.html
@@ -2,7 +2,7 @@
{% extends "admin/master.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
diff --git a/advlabdb/templates/analysis/assistant_marks.html b/advlabdb/templates/analysis/assistant_marks.html
index 8753375..a057857 100644
--- a/advlabdb/templates/analysis/assistant_marks.html
+++ b/advlabdb/templates/analysis/assistant_marks.html
@@ -2,7 +2,7 @@
{% extends "admin/master.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
diff --git a/advlabdb/templates/analysis/final_part_marks.html b/advlabdb/templates/analysis/final_part_marks.html
index 3692077..6136bbc 100644
--- a/advlabdb/templates/analysis/final_part_marks.html
+++ b/advlabdb/templates/analysis/final_part_marks.html
@@ -2,7 +2,7 @@
{% extends "admin/master.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
diff --git a/advlabdb/templates/assistant_create.html b/advlabdb/templates/assistant_create.html
index d16cf7e..edf8fe6 100644
--- a/advlabdb/templates/assistant_create.html
+++ b/advlabdb/templates/assistant_create.html
@@ -2,6 +2,6 @@
{% extends "admin/model/create.html" %}
{% block body %}
- {{information(current_user, active_semester, role="assistant")}}
+ {{information(current_user, active_semester_repr, role="assistant")}}
{{ super() }}
{% endblock %}
diff --git a/advlabdb/templates/assistant_details.html b/advlabdb/templates/assistant_details.html
index e2bca28..4d2ca18 100644
--- a/advlabdb/templates/assistant_details.html
+++ b/advlabdb/templates/assistant_details.html
@@ -2,6 +2,6 @@
{% extends "admin/model/details.html" %}
{% block body %}
- {{information(current_user, active_semester, role="assistant")}}
+ {{information(current_user, active_semester_repr, role="assistant")}}
{{ super() }}
{% endblock %}
diff --git a/advlabdb/templates/assistant_edit.html b/advlabdb/templates/assistant_edit.html
index c1435ad..a5be786 100644
--- a/advlabdb/templates/assistant_edit.html
+++ b/advlabdb/templates/assistant_edit.html
@@ -2,6 +2,6 @@
{% extends "admin/model/edit.html" %}
{% block body %}
- {{information(current_user, active_semester, role="assistant")}}
+ {{information(current_user, active_semester_repr, role="assistant")}}
{{ super() }}
{% endblock %}
diff --git a/advlabdb/templates/assistant_index.html b/advlabdb/templates/assistant_index.html
index 9ef0e7b..a6068df 100644
--- a/advlabdb/templates/assistant_index.html
+++ b/advlabdb/templates/assistant_index.html
@@ -2,7 +2,7 @@
{% extends "admin/index.html" %}
{% block body %}
- {{information(current_user, active_semester, role="assistant")}}
+ {{information(current_user, active_semester_repr, role="assistant")}}
diff --git a/advlabdb/templates/assistant_list.html b/advlabdb/templates/assistant_list.html
index 163442a..62098e0 100644
--- a/advlabdb/templates/assistant_list.html
+++ b/advlabdb/templates/assistant_list.html
@@ -2,6 +2,6 @@
{% extends "admin/model/list.html" %}
{% block body %}
- {{information(current_user, active_semester, role="assistant")}}
+ {{information(current_user, active_semester_repr, role="assistant")}}
{{ super() }}
{% endblock %}
diff --git a/advlabdb/templates/import.html b/advlabdb/templates/import.html
index 69a8205..005986c 100644
--- a/advlabdb/templates/import.html
+++ b/advlabdb/templates/import.html
@@ -2,7 +2,7 @@
{% extends "admin/master.html" %}
{% block body %}
- {{information(current_user, active_semester, role="admin")}}
+ {{information(current_user, active_semester_repr, role="admin")}}
diff --git a/advlabdb/templates/macros.html b/advlabdb/templates/macros.html
index 71ca8c4..cdd8df2 100644
--- a/advlabdb/templates/macros.html
+++ b/advlabdb/templates/macros.html
@@ -1,7 +1,7 @@
-{% macro information(current_user, active_semester, role) %}
+{% macro information(current_user, active_semester_repr, role) %}
User: {{ current_user.repr() }}
- | Active semester: {{ active_semester.repr() }}
+ | Active semester: {{ active_semester_repr() }}
{% if (role == "admin") and (current_user.has_role("assistant")) %}
| Assistant space.