1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +00:00

Added Jinja macros

This commit is contained in:
Mo 2021-07-29 20:03:41 +02:00
parent 8bf415220d
commit 8da20c23c3
8 changed files with 16 additions and 5 deletions

View file

@ -45,3 +45,4 @@ except Exception as ex:
print(
"\nYou are probably initializing the database with a script. If not, then you have to worry about not being able to import in __init__.py!\n"
)
print(str(ex))

View file

@ -38,6 +38,8 @@ from advlabdb.exceptions import ModelViewException
class UserView(SecureModelView):
can_view_details = True
column_list = ["email", "active", "roles", "assistant", "active_semester"]
column_searchable_list = ["email"]
column_filters = ["active", "active_semester", "assistant"]

View file

@ -7,7 +7,7 @@ from advlabdb.utils import setUserActiveSemester, userActiveSemester
@app.context_processor
def util_processor():
return dict(userActiveSemester=userActiveSemester)
return dict(userActiveSemester=userActiveSemester, current_user=current_user)
@app.route("/")

View file

@ -1,6 +1,7 @@
{% from "macros.html" import information %}
{% extends "admin/model/create.html" %}
{% block body %}
User's active semester: {{userActiveSemester().repr()}}
{{ information(current_user, userActiveSemester, role="admin") }}
{{super()}}
{% endblock %}

View file

@ -1,6 +1,7 @@
{% from "macros.html" import information %}
{% extends "admin/model/edit.html" %}
{% block body %}
User's active semester: {{userActiveSemester().repr()}}
{{ information(current_user, userActiveSemester, role="admin") }}
{{super()}}
{% endblock %}

View file

@ -1,7 +1,8 @@
{% from "macros.html" import information %}
{% extends "admin/index.html" %}
{% block body %}
User's active semester: {{userActiveSemester(flashWarning=True).repr()}}
{{ information(current_user, userActiveSemester, role="admin") }}
<h3>Welcome back, commander!</h3>
{{super()}}
{% endblock %}

View file

@ -1,6 +1,7 @@
{% from "macros.html" import information %}
{% extends "admin/model/list.html" %}
{% block body %}
User's active semester: {{userActiveSemester(flashWarning=True).repr()}}
{{ information(current_user, userActiveSemester, role="admin") }}
{{super()}}
{% endblock %}

View file

@ -0,0 +1,4 @@
{% macro information(current_user, userActiveSemester, role) %}
User: <a href="{{url_for('index')}}{{role}}/user/details/?id={{current_user.id}}">{{current_user.repr()}}</a>; Active
semester: {{userActiveSemester(flashWarning=True).repr()}}.
{% endmacro %}