Files
tesm-license/apps/tesm-license/src/tesm_license/blueprints/dashboard.py
T

41 lines
1.2 KiB
Python

"""Uebersicht -- die Startseite des Lizenzservers.
Anders als TESMs Geraete-Dashboard verlangt sie eine Anmeldung: das hier ist
eine interne Verwaltungsanwendung. Die Anmeldeseite ist der einzige sinnvolle
erste Einstiegspunkt.
"""
from __future__ import annotations
from flask import Blueprint, render_template
from tesm_core.auth.models import current_user, login_required
from tesm_core.extension import core, db
from ..services import issuance, reporting
bp = Blueprint("dashboard", __name__)
@bp.get("/overview")
@login_required
def index():
conn = db()
extension = core()
if not current_user.has("licenses.read"):
# Leere Huelle statt 403: die Startseite soll fuer jeden erreichbar
# bleiben, auch fuer ein Konto ohne Lizenzrechte.
return render_template("license/dashboard.html", summary=None, sources=[])
summary = issuance.dashboard_summary(conn)
return render_template(
"license/dashboard.html",
summary=summary,
sources=reporting.reporting_sources(conn) if current_user.has("reports.read") else [],
own_role=(extension.license.state.role if extension.license else "master"),
type_labels=dict(),
)
def index_view():
return index()