Shopfloor feed resolves employee names live when none is stored
Photos already resolved through the directory at read time, but names only came from the stored employeename column - empty after a shopdb-only import, so recertification/recognition cards showed bare SSOs. New resolve_employee_display_name in the employees plugin (mode-aware: self-hosted table or external HR) backs a fallback in both the single-card and split-per-employee paths; stored names still win when present.
This commit is contained in:
@@ -149,6 +149,16 @@ def _config_version():
|
||||
return hashlib.md5('||'.join(parts).encode()).hexdigest()[:12]
|
||||
|
||||
|
||||
def _employee_name(sso):
|
||||
"""Live directory name for an SSO; None on any miss. Used as the fallback
|
||||
when a notification has no stored employeename (see the shopfloor feed)."""
|
||||
try:
|
||||
from plugins.employees.api.routes import resolve_employee_display_name
|
||||
return resolve_employee_display_name(sso)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def _employee_picture(sso):
|
||||
"""Resolved display photo URL for an SSO, via the shared employees-plugin
|
||||
resolver so kiosk cards match EmployeeDetail in both directory modes
|
||||
@@ -723,7 +733,12 @@ def get_shopfloor_notifications():
|
||||
result['employeepicture'] = employee_override.get('picture')
|
||||
else:
|
||||
result['employeesso'] = n.employeesso
|
||||
result['employeename'] = n.employeename
|
||||
# Stored name first (import/manual entry), else resolve live from
|
||||
# the directory so shopdb-only imports still show names.
|
||||
name = n.employeename
|
||||
if not name and n.employeesso and ',' not in n.employeesso:
|
||||
name = _employee_name(n.employeesso)
|
||||
result['employeename'] = name
|
||||
result['employeepicture'] = _employee_picture(n.employeesso) if show_photo else None
|
||||
|
||||
return result
|
||||
@@ -742,7 +757,8 @@ def get_shopfloor_notifications():
|
||||
return [
|
||||
notification_to_shopfloor(n, {
|
||||
'sso': sso,
|
||||
'name': names[i] if i < len(names) else sso,
|
||||
'name': (names[i] if i < len(names) and names[i] else None)
|
||||
or _employee_name(sso) or sso,
|
||||
'picture': _employee_picture(sso) if show_photo else None,
|
||||
})
|
||||
for i, sso in enumerate(ssos)
|
||||
|
||||
Reference in New Issue
Block a user