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:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user