Shopfloor feed resolves employee names live when none is stored
Some checks failed
CI / backend (push) Successful in 1m45s
CI / naming (push) Successful in 1s
CI / frontend (push) Successful in 8s
CI / migrations-mysql (push) Failing after 8s

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:
cproudlock
2026-07-17 13:29:34 -04:00
parent bc9159742c
commit ee80d684d4
3 changed files with 77 additions and 2 deletions

View File

@@ -70,3 +70,32 @@ def test_single_employee_recognition_stays_single_card(client, db):
current = resp.get_json()['data']['current']
assert len(current) == 1
assert current[0]['employeesso'] == '111'
def test_shopfloor_names_resolve_live_when_not_stored(client, app, db):
"""A notification imported without employeename shows the directory name,
not the bare SSO - single and split-per-employee paths both."""
from plugins.employees.models import DirectoryEmployee
from plugins.notifications.models import Notification, NotificationType
from shopdb.core.models import Setting
with app.app_context():
Setting.set('employee_directory_mode', 'selfhosted',
valuetype='string', category='employees')
db.session.add(DirectoryEmployee(
sso=502000777, firstname='Recert', lastname='Person'))
ntype = NotificationType(typename='Recertification',
typecolor='recertification',
splitperemployee=True)
db.session.add(ntype)
db.session.flush()
db.session.add(Notification(
notificationtypeid=ntype.notificationtypeid,
notification='Recert due', isshopfloor=True,
employeesso='502000777', employeename=None))
db.session.commit()
feed = client.get('/api/notifications/shopfloor').get_json()['data']
cards = feed['current'] + feed['upcoming']
card = next(c for c in cards if c['notification'] == 'Recert due')
assert card['employeename'] == 'Recert Person'