diff --git a/blueprints/admin/routes.py b/blueprints/admin/routes.py index eb40e2c..2a6a229 100644 --- a/blueprints/admin/routes.py +++ b/blueprints/admin/routes.py @@ -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: diff --git a/templates/admin/users.html b/templates/admin/users.html index 2e920cb..e278b92 100644 --- a/templates/admin/users.html +++ b/templates/admin/users.html @@ -1245,8 +1245,8 @@ {{ user.created_at.strftime('%d.%m.%Y %H:%M') }} - {% if user.created_by_id %} -
dodał: {{ user.created_by.name or user.created_by.email }} + {% if user.created_by_id and creators_map.get(user.created_by_id) %} +
dodał: {{ creators_map[user.created_by_id] }} {% else %}
samorejestracja {% endif %}