35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""
|
|
Accountverwaltung
|
|
"""
|
|
from flask import Blueprint, make_response, render_template, g
|
|
from cmbnet.auth import role_required
|
|
from cmbnet.db import get_db
|
|
from cmbnet.services.api_token_service import ApiTokenService
|
|
|
|
admin_accounts_bp = Blueprint('admin', __name__)
|
|
|
|
|
|
@admin_accounts_bp.route('/dashboard')
|
|
@role_required('Administrator')
|
|
def dashboard(**kwargs):
|
|
"""Admin Dashboard"""
|
|
response = make_response(render_template(
|
|
'admin/dashboard.html',
|
|
api_tokens=ApiTokenService.list_for_tenant(g.tenant_id)
|
|
))
|
|
# Die Seite enthält Zugriffstoken und darf nicht im Browser-Cache landen.
|
|
response.headers['Cache-Control'] = 'no-store'
|
|
return response
|
|
|
|
|
|
@admin_accounts_bp.route('/accounts')
|
|
@role_required('Administrator')
|
|
def accounts(**kwargs):
|
|
"""Accountverwaltung"""
|
|
db = get_db()
|
|
accounts = db.execute(
|
|
'SELECT a.*, t.code as tenant_code FROM accounts a JOIN tenants t ON a.tenant_id = t.id WHERE a.tenant_id = ? ORDER BY a.id',
|
|
(g.tenant_id,)
|
|
).fetchall()
|
|
return render_template('admin/accounts.html', accounts=accounts)
|