fix: resolve event titles before prefix match in _humanize_path
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

Event paths like /kalendarz/29 were matched by the /kalendarz/
prefix before reaching the dynamic event title lookup. Reorder
to check dynamic patterns (event ID, company slug) first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-03-10 19:32:10 +01:00
parent 8c6715e915
commit c62e5827d6

View File

@ -758,32 +758,15 @@ PATH_LABELS = {
def _humanize_path(path, db=None, _cache={}):
"""Convert raw path to human-readable label."""
import re
if not path:
return path
# Exact match
# Exact match first
if path in PATH_LABELS:
return PATH_LABELS[path]
# Prefix match (e.g. /forum/topic/5 → Forum)
for prefix, label in PATH_LABELS.items():
if prefix.endswith('/') and path.startswith(prefix) and prefix != '/':
rest = path[len(prefix):]
if rest and not rest.startswith('admin'):
return f'{label}: {rest}'
return label
# Dynamic: /company/<slug> → Company name
import re
company_match = re.match(r'^/company/([a-z0-9-]+)$', path)
if company_match and db:
slug = company_match.group(1)
if slug not in _cache:
co = db.query(Company.name).filter_by(slug=slug).first()
_cache[slug] = co.name if co else slug
return _cache[slug]
# Dynamic: /kalendarz/<id> → Event title
# Dynamic: /kalendarz/<id> → Event title (BEFORE prefix match)
event_match = re.match(r'^/kalendarz/(\d+)(/.*)?$', path)
if event_match and db:
eid = int(event_match.group(1))
@ -797,6 +780,23 @@ def _humanize_path(path, db=None, _cache={}):
return f'{name} (RSVP)'
return name
# Dynamic: /company/<slug> → Company name
company_match = re.match(r'^/company/([a-z0-9-]+)$', path)
if company_match and db:
slug = company_match.group(1)
if slug not in _cache:
co = db.query(Company.name).filter_by(slug=slug).first()
_cache[slug] = co.name if co else slug
return _cache[slug]
# Prefix match (e.g. /forum/topic/5 → Forum: topic/5)
for prefix, label in PATH_LABELS.items():
if prefix.endswith('/') and path.startswith(prefix) and prefix != '/':
rest = path[len(prefix):]
if rest and not rest.startswith('admin'):
return f'{label}: {rest}'
return label
# Admin paths
if path.startswith('/admin/'):
return path.replace('/admin/', 'Admin: ').replace('-', ' ').title()