feat(izba): chamber roles — badges on profiles + Władze Izby page
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
- Added chamber_role column to User model (prezes, wiceprezes, czlonek_rady, komisja_rewizyjna, sad_kolezenski) - Migration 089 sets roles for all known members from norda-biznes.info/wladze-izby - Role badges on user profile, person detail, and company contact persons - New page /izba/wladze showing all chamber authorities grouped by organ - Color-coded badges: gold (prezes), blue (wiceprezes), green (rada), purple (komisja), gray (sąd) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0f2de4cfcd
commit
0c2aadd42f
@ -277,6 +277,44 @@ def api_upcoming_events():
|
||||
db.close()
|
||||
|
||||
|
||||
@bp.route('/izba/wladze')
|
||||
@login_required
|
||||
def chamber_authorities():
|
||||
"""Władze Izby — Zarząd, Rada, Komisja Rewizyjna, Sąd Koleżeński"""
|
||||
from utils.decorators import member_required
|
||||
db = SessionLocal()
|
||||
try:
|
||||
# Group users by chamber role
|
||||
all_with_roles = db.query(User).filter(
|
||||
User.chamber_role.isnot(None),
|
||||
User.is_active == True
|
||||
).order_by(User.name).all()
|
||||
|
||||
groups = {
|
||||
'zarzad': {'title': 'Zarząd Izby', 'icon': '👔', 'members': []},
|
||||
'rada': {'title': 'Rada Izby', 'icon': '🏛️', 'members': []},
|
||||
'komisja': {'title': 'Komisja Rewizyjna', 'icon': '📋', 'members': []},
|
||||
'sad': {'title': 'Sąd Koleżeński', 'icon': '⚖️', 'members': []},
|
||||
}
|
||||
|
||||
for u in all_with_roles:
|
||||
if u.chamber_role in ('prezes', 'wiceprezes'):
|
||||
groups['zarzad']['members'].append(u)
|
||||
elif u.chamber_role == 'czlonek_rady':
|
||||
groups['rada']['members'].append(u)
|
||||
elif u.chamber_role == 'komisja_rewizyjna':
|
||||
groups['komisja']['members'].append(u)
|
||||
elif u.chamber_role == 'sad_kolezenski':
|
||||
groups['sad']['members'].append(u)
|
||||
|
||||
# Sort zarząd: prezes first, then wiceprezesi
|
||||
groups['zarzad']['members'].sort(key=lambda u: (0 if u.chamber_role == 'prezes' else 1, u.name))
|
||||
|
||||
return render_template('chamber_authorities.html', groups=groups)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@bp.route('/company/<int:company_id>')
|
||||
def company_detail(company_id):
|
||||
"""Company detail page - requires login and NORDA membership"""
|
||||
|
||||
12
database.py
12
database.py
@ -293,6 +293,7 @@ class User(Base, UserMixin):
|
||||
is_admin = Column(Boolean, default=False) # DEPRECATED: synced by set_role() for backward compat. Use has_role(SystemRole.ADMIN) instead. Will be removed in future migration.
|
||||
is_norda_member = Column(Boolean, default=False)
|
||||
is_rada_member = Column(Boolean, default=False) # Member of Rada Izby (Board Council)
|
||||
chamber_role = Column(String(50)) # prezes, wiceprezes, czlonek_rady, komisja_rewizyjna, sad_kolezenski
|
||||
avatar_path = Column(String(500)) # Path to profile photo (relative to static/uploads/)
|
||||
|
||||
# Timestamps
|
||||
@ -343,6 +344,17 @@ class User(Base, UserMixin):
|
||||
|
||||
# === ROLE SYSTEM HELPER METHODS ===
|
||||
|
||||
@property
|
||||
def chamber_role_label(self):
|
||||
labels = {
|
||||
'prezes': 'Prezes Izby',
|
||||
'wiceprezes': 'Wiceprezes Izby',
|
||||
'czlonek_rady': 'Członek Rady Izby',
|
||||
'komisja_rewizyjna': 'Komisja Rewizyjna',
|
||||
'sad_kolezenski': 'Sąd Koleżeński',
|
||||
}
|
||||
return labels.get(self.chamber_role)
|
||||
|
||||
@property
|
||||
def system_role(self) -> SystemRole:
|
||||
"""Get the user's SystemRole enum value."""
|
||||
|
||||
26
database/migrations/089_chamber_role.sql
Normal file
26
database/migrations/089_chamber_role.sql
Normal file
@ -0,0 +1,26 @@
|
||||
BEGIN;
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS chamber_role VARCHAR(50);
|
||||
|
||||
-- Zarząd
|
||||
UPDATE users SET chamber_role = 'prezes' WHERE email = 'leszek.glaza@nordatools.pl';
|
||||
|
||||
-- Find Paweł Kwidziński, Janusz Masiak, Artur Wiertel by name and set wiceprezes
|
||||
UPDATE users SET chamber_role = 'wiceprezes' WHERE name ILIKE '%Kwidziński%' OR name ILIKE '%Kwi%ziński%';
|
||||
UPDATE users SET chamber_role = 'wiceprezes' WHERE name ILIKE '%Masiak%';
|
||||
UPDATE users SET chamber_role = 'wiceprezes' WHERE name ILIKE '%Wiertel%' AND name ILIKE '%Artur%';
|
||||
|
||||
-- Komisja Rewizyjna
|
||||
UPDATE users SET chamber_role = 'komisja_rewizyjna' WHERE name ILIKE '%Nurzyński%';
|
||||
UPDATE users SET chamber_role = 'komisja_rewizyjna' WHERE name ILIKE '%Więcek%' AND name ILIKE '%Marek%';
|
||||
UPDATE users SET chamber_role = 'komisja_rewizyjna' WHERE name ILIKE '%Karnikowska%';
|
||||
|
||||
-- Sąd Koleżeński
|
||||
UPDATE users SET chamber_role = 'sad_kolezenski' WHERE name ILIKE '%Morske%';
|
||||
UPDATE users SET chamber_role = 'sad_kolezenski' WHERE name ILIKE '%Mizak%';
|
||||
UPDATE users SET chamber_role = 'sad_kolezenski' WHERE name ILIKE '%Domachowska%';
|
||||
|
||||
-- Rada Izby members (already have is_rada_member=true) - set role for those without specific role
|
||||
UPDATE users SET chamber_role = 'czlonek_rady' WHERE is_rada_member = true AND chamber_role IS NULL;
|
||||
|
||||
GRANT ALL ON TABLE users TO nordabiz_app;
|
||||
COMMIT;
|
||||
180
templates/chamber_authorities.html
Normal file
180
templates/chamber_authorities.html
Normal file
@ -0,0 +1,180 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Władze Izby - Norda Biznes Partner{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
.authorities-container {
|
||||
max-width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.authorities-header {
|
||||
text-align: center;
|
||||
margin-bottom: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.authorities-header h1 {
|
||||
font-size: var(--font-size-2xl);
|
||||
color: var(--text-primary);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.authorities-header p {
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.authority-group {
|
||||
margin-bottom: var(--spacing-xl);
|
||||
}
|
||||
|
||||
.authority-group-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
margin-bottom: var(--spacing-md);
|
||||
padding-bottom: var(--spacing-sm);
|
||||
border-bottom: 2px solid var(--border-color, #e5e7eb);
|
||||
}
|
||||
|
||||
.authority-group-header h2 {
|
||||
font-size: var(--font-size-lg);
|
||||
color: var(--text-primary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.authority-group-icon {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.authority-members {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.authority-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-md);
|
||||
padding: var(--spacing-md);
|
||||
background: white;
|
||||
border-radius: var(--radius-lg);
|
||||
border: 1px solid var(--border-color, #e5e7eb);
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.authority-card:hover {
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 4px 12px rgba(46, 72, 114, 0.1);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.authority-avatar {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, var(--primary), #8b5cf6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.authority-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.authority-avatar-initial {
|
||||
color: white;
|
||||
font-weight: 700;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.authority-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.authority-name {
|
||||
font-weight: 600;
|
||||
font-size: var(--font-size-base);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.authority-role {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
display: inline-block;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.role-prezes { background: #fef3c7; color: #92400e; }
|
||||
.role-wiceprezes { background: #dbeafe; color: #1d4ed8; }
|
||||
.role-czlonek_rady { background: #ecfdf5; color: #065f46; }
|
||||
.role-komisja_rewizyjna { background: #f3e8ff; color: #6b21a8; }
|
||||
.role-sad_kolezenski { background: #f3f4f6; color: #4b5563; }
|
||||
|
||||
.authority-company {
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--text-secondary);
|
||||
margin-top: 2px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.authority-members {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="authorities-container">
|
||||
<div class="authorities-header">
|
||||
<h1>Władze Izby Norda Biznes</h1>
|
||||
<p>Kadencja 2023–2026</p>
|
||||
</div>
|
||||
|
||||
{% for key, group in groups.items() %}
|
||||
{% if group.members %}
|
||||
<div class="authority-group">
|
||||
<div class="authority-group-header">
|
||||
<span class="authority-group-icon">{{ group.icon }}</span>
|
||||
<h2>{{ group.title }}</h2>
|
||||
<span style="color: var(--text-muted); font-size: var(--font-size-sm); font-weight: normal;">({{ group.members|length }})</span>
|
||||
</div>
|
||||
<div class="authority-members">
|
||||
{% for user in group.members %}
|
||||
<a href="{{ url_for('public.user_profile', user_id=user.id) }}" class="authority-card">
|
||||
<div class="authority-avatar">
|
||||
{% if user.avatar_path %}
|
||||
<img src="{{ url_for('static', filename=user.avatar_path) }}" alt="">
|
||||
{% else %}
|
||||
<span class="authority-avatar-initial">{{ (user.name or user.email)[0].upper() }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="authority-info">
|
||||
<div class="authority-name">{{ user.name or user.email.split('@')[0] }}</div>
|
||||
<span class="authority-role role-{{ user.chamber_role }}">{{ user.chamber_role_label }}</span>
|
||||
{% if user.company %}
|
||||
<div class="authority-company">{{ user.company.name }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -1720,6 +1720,10 @@
|
||||
{% elif uc.role == 'EMPLOYEE' %}
|
||||
<span style="font-size: 11px; background: #f3f4f6; color: #4b5563; padding: 2px 8px; border-radius: 4px; font-weight: 600;">Pracownik</span>
|
||||
{% endif %}
|
||||
{% if uc.user.chamber_role_label %}
|
||||
{% set _cr = uc.user.chamber_role %}
|
||||
<span style="font-size: 11px; background: {{ '#fef3c7' if _cr == 'prezes' else '#dbeafe' if _cr == 'wiceprezes' else '#f3e8ff' if _cr == 'komisja_rewizyjna' else '#f3f4f6' if _cr == 'sad_kolezenski' else '#ecfdf5' }}; color: {{ '#92400e' if _cr == 'prezes' else '#1d4ed8' if _cr == 'wiceprezes' else '#6b21a8' if _cr == 'komisja_rewizyjna' else '#4b5563' if _cr == 'sad_kolezenski' else '#065f46' }}; padding: 2px 8px; border-radius: 4px; font-weight: 600;">{{ uc.user.chamber_role_label }}</span>
|
||||
{% endif %}
|
||||
{% if uc.user.is_norda_member %}
|
||||
<span style="font-size: 11px; background: #ecfdf5; color: #065f46; padding: 2px 8px; border-radius: 4px; font-weight: 600;">Norda</span>
|
||||
{% endif %}
|
||||
|
||||
@ -245,8 +245,11 @@
|
||||
</div>
|
||||
<h1 class="person-name">
|
||||
{{ person.full_name() }}
|
||||
{% if is_rada_member %}
|
||||
<span style="display:inline-block;background:#f59e0b;color:#92400e;font-size:12px;padding:3px 10px;border-radius:20px;font-weight:600;vertical-align:middle;margin-left:8px;">Rada Izby</span>
|
||||
{% if person.user and person.user.chamber_role_label %}
|
||||
{% set _cr = person.user.chamber_role %}
|
||||
<span style="display:inline-block;background:{{ '#fef3c7' if _cr == 'prezes' else '#dbeafe' if _cr == 'wiceprezes' else '#f3e8ff' if _cr == 'komisja_rewizyjna' else '#f3f4f6' if _cr == 'sad_kolezenski' else '#ecfdf5' }};color:{{ '#92400e' if _cr == 'prezes' else '#1d4ed8' if _cr == 'wiceprezes' else '#6b21a8' if _cr == 'komisja_rewizyjna' else '#4b5563' if _cr == 'sad_kolezenski' else '#065f46' }};font-size:12px;padding:3px 10px;border-radius:20px;font-weight:600;vertical-align:middle;margin-left:8px;">{{ person.user.chamber_role_label }}</span>
|
||||
{% elif is_rada_member %}
|
||||
<span style="display:inline-block;background:#ecfdf5;color:#065f46;font-size:12px;padding:3px 10px;border-radius:20px;font-weight:600;vertical-align:middle;margin-left:8px;">Rada Izby</span>
|
||||
{% endif %}
|
||||
</h1>
|
||||
{% set unique_company_ids = company_roles|map(attribute='company_id')|list|unique|list %}
|
||||
|
||||
@ -219,8 +219,11 @@
|
||||
</div>
|
||||
<h1 class="profile-name">
|
||||
{{ profile_user.name or 'Użytkownik' }}
|
||||
{% if profile_user.is_rada_member %}
|
||||
<span style="display:inline-block;background:#f59e0b;color:#92400e;font-size:12px;padding:3px 10px;border-radius:20px;font-weight:600;vertical-align:middle;margin-left:8px;">Rada Izby</span>
|
||||
{% if profile_user.chamber_role_label %}
|
||||
{% set _cr = profile_user.chamber_role %}
|
||||
<span style="display:inline-block;background:{{ '#fef3c7' if _cr == 'prezes' else '#dbeafe' if _cr == 'wiceprezes' else '#f3e8ff' if _cr == 'komisja_rewizyjna' else '#f3f4f6' if _cr == 'sad_kolezenski' else '#ecfdf5' }};color:{{ '#92400e' if _cr == 'prezes' else '#1d4ed8' if _cr == 'wiceprezes' else '#6b21a8' if _cr == 'komisja_rewizyjna' else '#4b5563' if _cr == 'sad_kolezenski' else '#065f46' }};font-size:12px;padding:3px 10px;border-radius:20px;font-weight:600;vertical-align:middle;margin-left:8px;">{{ profile_user.chamber_role_label }}</span>
|
||||
{% elif profile_user.is_rada_member %}
|
||||
<span style="display:inline-block;background:#ecfdf5;color:#065f46;font-size:12px;padding:3px 10px;border-radius:20px;font-weight:600;vertical-align:middle;margin-left:8px;">Rada Izby</span>
|
||||
{% endif %}
|
||||
</h1>
|
||||
<p class="profile-subtitle">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user