blob: 90d65e0bf3fe5f15bf5dc05e3aca255ec5f13857 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
"""UI utilities"""
from flask import session, render_template
from .client import oauth2_get
from .client import user_logged_in
from .request_utils import process_error
def render_ui(templatepath: str, **kwargs):
"""Handle repetitive UI rendering stuff."""
roles = kwargs.get("roles", tuple()) # Get roles
user_privileges = tuple(
privilege for role in roles for privilege in role["privileges"])
kwargs = {
**kwargs, "roles": roles, "user_privileges": user_privileges
}
return render_template(templatepath, **kwargs)
|