fix(users): use creators_map instead of relationship for created_by display
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Self-referential FK with lazy='joined' causes DetachedInstanceError after db.close(). Build a simple dict lookup in the route instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3c39980624
commit
3df362f44e
@ -168,6 +168,13 @@ def admin_users():
|
||||
|
||||
locked_count = sum(1 for u in users if u.locked_until and u.locked_until > datetime.utcnow())
|
||||
|
||||
# Build created_by map: user_id → creator name (for "added by" display)
|
||||
creator_ids = {u.created_by_id for u in users if u.created_by_id}
|
||||
creators_map = {}
|
||||
if creator_ids:
|
||||
creators = db.query(User.id, User.name, User.email).filter(User.id.in_(creator_ids)).all()
|
||||
creators_map = {c.id: c.name or c.email for c in creators}
|
||||
|
||||
return render_template(
|
||||
'admin/users.html',
|
||||
users=users,
|
||||
@ -178,6 +185,7 @@ def admin_users():
|
||||
unverified_count=unverified_count,
|
||||
pending_company_count=pending_company_count,
|
||||
locked_count=locked_count,
|
||||
creators_map=creators_map,
|
||||
now=datetime.utcnow()
|
||||
)
|
||||
finally:
|
||||
|
||||
@ -1245,8 +1245,8 @@
|
||||
<td style="font-size: var(--font-size-sm); color: var(--text-secondary);"
|
||||
data-sort-value="{{ user.created_at.strftime('%Y%m%d%H%M') }}">
|
||||
{{ user.created_at.strftime('%d.%m.%Y %H:%M') }}
|
||||
{% if user.created_by_id %}
|
||||
<br><span style="font-size: 0.75rem; color: var(--text-muted, #9CA3AF);" title="Dodany przez {{ user.created_by.name or user.created_by.email }}">dodał: {{ user.created_by.name or user.created_by.email }}</span>
|
||||
{% if user.created_by_id and creators_map.get(user.created_by_id) %}
|
||||
<br><span style="font-size: 0.75rem; color: var(--text-muted, #9CA3AF);" title="Dodany przez {{ creators_map[user.created_by_id] }}">dodał: {{ creators_map[user.created_by_id] }}</span>
|
||||
{% else %}
|
||||
<br><span style="font-size: 0.75rem; color: var(--text-muted, #9CA3AF);">samorejestracja</span>
|
||||
{% endif %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user