Add account details view for admin

This commit is contained in:
2026-05-17 11:08:48 +02:00
parent 3f97facd7c
commit a522a3b110
4 changed files with 93 additions and 1 deletions

View File

@@ -387,3 +387,26 @@ async def add_balance_to_account(
return RedirectResponse(
url="/admin/accounts", status_code=status.HTTP_303_SEE_OTHER
)
@admin_router.get("/accounts/{account_id}/details")
async def view_account_details(
request: Request,
session: SessionDep,
user: UserDep,
account_id: int,
):
if not user.has_permission("account", "edit"):
raise HTTPException(status_code=403, detail="Insufficient permissions")
account = session.execute(
select(Account).where(Account.id == account_id)
).scalar_one()
templates = get_jinja_renderer()
return templates.TemplateResponse(
request,
"account_details.html.jinja",
context={"account": account},
)

View File

@@ -0,0 +1,68 @@
{% extends "base.html.jinja" %}
{% block content %}
<!-- Account Balances Section -->
<div class="mb-4">
<h2 class="h4 mb-3">Kontodetails für Konto "{{account.name}}"</h2>
<div class="row g-3">
<div class="col-md-6 col-lg-4">
<div class="card border-primary border-3 shadow-lg">
<div class="card-body">
<h5 class="card-title">{{ account.name }}</h5>
<p class="h3 mb-2 {% if account.balance < 0 %}text-danger{% else %}text-success{% endif %}">
{{ account.balance | format_number }} €
</p>
</div>
</div>
</div>
</div>
</div>
<!-- Latest Transactions Section -->
<div class="transactions-section">
<div class="card">
<div class="list-group list-group-flush">
{% if account.transactions|length > 0 %}
{% for transaction in account.transactions %}
<div class="list-group-item d-flex justify-content-between align-items-start py-3">
<div class="flex-grow-1">
<div class="fw-semibold d-inline">{{ transaction.type|transaction_type_de }}</div>
<small class="text-muted d-inline ms-2">
{{ transaction.timestamp | timestamp_de }}
</small>
{% if transaction.type == "order" %}
<div class="mt-2">
{% if transaction.order and transaction.order.items|length > 0 %}
<div class="small text-muted mb-2">
{% for item in transaction.order.items[:3] %}
{{ item.product.current_details.name }}{% if loop.index < transaction.order.items[:3]|length %},{% endif %}
{% endfor %}
{% if transaction.order.items|length > 3 %}
<div class="text-muted">+ {{ transaction.order.items|length - 3 }} weitere{% if transaction.order.items|length - 3 == 1 %} Artikel{% else %} Artikel{% endif %}</div>
{% endif %}
</div>
{% endif %}
<a href="/shop/order/{{ transaction.order_id }}" class="btn btn-sm btn-outline-primary">Einkauf ansehen</a>
</div>
{% endif %}
</div>
<div class="text-end ms-3">
<span class="fs-5 fw-bold {% if transaction.total_amount < 0 %}text-danger{% else %}text-success{% endif %}">
{{ transaction.total_amount | format_number }} €
</span>
{% if transaction.quantity %}
<div class="small text-muted">{{ transaction.quantity }}</div>
{% endif %}
</div>
</div>
{% endfor %}
{% else %}
<div class="list-group-item text-center py-5 text-muted">
<p class="mb-0">Noch keine Buchungen</p>
<small>Deine Buchungen werden hier erscheinen</small>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}

View File

@@ -48,6 +48,7 @@
<td>{{ account.users | map(attribute='display_name') | join(", ") }}</td>
<td>{{ account.balance | format_number }} €</td>
<td>
<a class="btn btn-sm btn-primary" href="/admin/accounts/{{account.id}}/details">Details ansehen</a>
<button type="button" class="btn btn-sm btn-outline-primary" data-bs-toggle="modal" data-bs-target="#addUserModal-{{ account.id }}">Benutzer hinzufügen</button>
<button type="button" class="btn btn-sm btn-outline-primary" data-bs-toggle="modal" data-bs-target="#addBalanceModal-{{ account.id }}">Guthaben hinzufügen</button>

View File

@@ -56,7 +56,7 @@
{% if transaction.order and transaction.order.items|length > 0 %}
<div class="small text-muted mb-2">
{% for item in transaction.order.items[:3] %}
{{ item.product.name }}{% if loop.index < transaction.order.items[:3]|length %},{% endif %}
{{ item.product.current_details.name }}{% if loop.index < transaction.order.items[:3]|length %},{% endif %}
{% endfor %}
{% if transaction.order.items|length > 3 %}
<div class="text-muted">+ {{ transaction.order.items|length - 3 }} weitere{% if transaction.order.items|length - 3 == 1 %} Artikel{% else %} Artikel{% endif %}</div>