diff --git a/blueprints/public/routes.py b/blueprints/public/routes.py index 00a6c2e..8bf4551 100644 --- a/blueprints/public/routes.py +++ b/blueprints/public/routes.py @@ -824,10 +824,31 @@ def search(): logger.info(f"Search '{query}': {len(people_results)} people found") + # Also search portal users (not yet in people_results via person_id) + user_results = [] + if query and len(query) >= 2: + q = f"%{query}%" + matched_users = db.query(User).filter( + User.is_active == True, + User.is_verified == True, + User.name.ilike(q) + ).limit(20).all() + + # Exclude users who are already in people_results (via person_id) + people_person_ids = {p.id for p in people_results} + for u in matched_users: + if u.person_id and u.person_id in people_person_ids: + continue # already shown as Person + user_results.append(u) + + if user_results: + logger.info(f"Search '{query}': {len(user_results)} portal users found") + return render_template( 'search_results.html', companies=companies, people=people_results, + user_results=user_results, query=query, category_id=category_id, result_count=len(companies), diff --git a/templates/search_results.html b/templates/search_results.html index 786f49f..e6d7965 100755 --- a/templates/search_results.html +++ b/templates/search_results.html @@ -242,7 +242,7 @@ {% if query %}

Znaleziono {{ companies|length }} firm - {%- if people %} i {{ people|length }} osób{% endif %} + {%- if people or user_results %} i {{ (people|length) + (user_results|length) }} osób{% endif %} dla zapytania: "{{ query }}"

{% else %} @@ -283,6 +283,44 @@ {% endif %} +{% if user_results %} +
+

+ + + + Użytkownicy portalu ({{ user_results|length }}) +

+
+ {% for user in user_results %} + +
+ {% if user.avatar_path %} + + {% else %} + {{ (user.name or user.email)[0].upper() }} + {% endif %} +
+
+ +
+ {% if user.company %}{{ user.company.name }}{% else %}Członek portalu{% endif %} +
+
+
+ {% endfor %} +
+
+{% endif %} + {% if companies %}
{% for company in companies %} @@ -341,7 +379,7 @@
{% endif %} -{% if not companies and not people %} +{% if not companies and not people and not user_results %}