diff --git a/app.py b/app.py index 15596d2..3dbe38d 100644 --- a/app.py +++ b/app.py @@ -665,6 +665,55 @@ def company_detail_by_slug(slug): db.close() +@app.route('/osoba/') +def person_detail(person_id): + """Person detail page - shows registry data and portal data if available""" + db = SessionLocal() + try: + # Get person with their company relationships + person = db.query(Person).filter_by(id=person_id).first() + if not person: + flash('Osoba nie znaleziona.', 'error') + return redirect(url_for('index')) + + # Get company roles with company details (only active companies) + company_roles = db.query(CompanyPerson).filter_by( + person_id=person_id + ).join(Company, CompanyPerson.company_id == Company.id).filter( + Company.status == 'active' + ).order_by( + CompanyPerson.role_category, + Company.name + ).all() + + # Try to find matching user account by name (for portal data) + # This is a simple match - in production might need more sophisticated matching + portal_user = None + name_parts = person.full_name().upper().split() + if len(name_parts) >= 2: + # Try to find user where first/last name matches + potential_users = db.query(User).filter( + User.full_name.isnot(None) + ).all() + for u in potential_users: + if u.full_name: + user_name_parts = u.full_name.upper().split() + # Check if at least first and last name match + if len(user_name_parts) >= 2: + if (user_name_parts[-1] in name_parts and # Last name match + any(part in user_name_parts for part in name_parts[:-1])): # First name match + portal_user = u + break + + return render_template('person_detail.html', + person=person, + company_roles=company_roles, + portal_user=portal_user + ) + finally: + db.close() + + @app.route('/company//recommend', methods=['GET', 'POST']) # @login_required # Disabled - public access def company_recommend(slug): diff --git a/templates/connections_modal.html b/templates/connections_modal.html index f513ffb..55f7b8c 100644 --- a/templates/connections_modal.html +++ b/templates/connections_modal.html @@ -959,15 +959,16 @@ function initModalGraph(nodes, links) { html += `

Powiązany z ${uniqueCompanyCount} firmami (${connected.length} ról)

`; if (connected.length > 0) { - connected.slice(0, 5).forEach(l => { + // Show ALL companies, no limit + connected.forEach(l => { const tId = typeof l.target === 'object' ? l.target.id : l.target; const company = nodes.find(n => n.id === tId); if (company && company.type === 'company') { html += `${l.role}${company.name}
`; } }); - if (connected.length > 5) html += `

...i ${connected.length - 5} więcej

`; } + html += `

Kliknij, aby zobaczyć profil

`; } tooltip.html(html) @@ -988,9 +989,11 @@ function initModalGraph(nodes, links) { if (d.type === 'company' && d.slug) { closeConnectionsMap(); window.location.href = `/company/${d.slug}`; - } else { - // Select this node to filter - selectNode(d.id); + } else if (d.type === 'person') { + // Navigate to person profile + const personId = d.id.replace('person_', ''); + closeConnectionsMap(); + window.location.href = `/osoba/${personId}`; } }); diff --git a/templates/person_detail.html b/templates/person_detail.html new file mode 100644 index 0000000..f0764a3 --- /dev/null +++ b/templates/person_detail.html @@ -0,0 +1,290 @@ +{% extends "base.html" %} + +{% block title %}{{ person.full_name() }} - Norda Biznes Hub{% endblock %} + +{% block extra_css %} + +{% endblock %} + +{% block content %} +
+ + + + + Wstecz + + + +
+
+ {{ person.imiona[0] }}{{ person.nazwisko[0] }} +
+

{{ person.full_name() }}

+

+ Powiazany z {{ company_roles|length }} firmami w Norda Biznes +

+
+ + + {% if portal_user %} +
+

+ + + + Dane kontaktowe (z konta na portalu) +

+
+ {% if portal_user.email %} + + {% endif %} + {% if portal_user.phone %} + + {% endif %} + {% if portal_user.company %} +
+ + + + {{ portal_user.company.name if portal_user.company else '-' }} +
+ {% endif %} +
+
+ {% else %} +
+

+ + + + Dane kontaktowe +

+
+ Ta osoba nie ma jeszcze konta na portalu Norda Biznes Hub. Dane kontaktowe pojawia sie po rejestracji. +
+
+ {% endif %} + + +
+

+ + + + Powiazania z firmami +

+ + {% set unique_companies = {} %} + {% for role in company_roles %} + {% if role.company.id not in unique_companies %} + {% set _ = unique_companies.update({role.company.id: {'company': role.company, 'roles': []}}) %} + {% endif %} + {% set _ = unique_companies[role.company.id]['roles'].append(role) %} + {% endfor %} + + {% for company_id, data in unique_companies.items() %} + + {% endfor %} + +
+ Dane urzedowe pochodza z: + ekrs.ms.gov.pl (KRS), + dane.biznes.gov.pl (CEIDG) +
+
+
+{% endblock %}