Files

37 lines
1.2 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
from cmbnet.admin.backup import collect_config_items
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),
config_items=collect_config_items()
))
# 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)