dashboard: resolve employee names from directory/user, GE monogram photo fallback, kiosk sweep + label

- notifications shopfloor feed: resolve the employee name live when the stored
  value is a bare SSO (WJ notifications imported as SSOs, never converted), for
  both single and split-per-employee cards
- employee name resolver: after a directory miss, fall back to the shopdb User
  account (firstname/lastname, keyed by SSO username) so users from other
  locations still show a name
- shopfloor dashboard: employee photo falls back to the GE monogram (own asset,
  independent of the site_logo setting) with a loop-guarded onerror; recognition
  + recert tiles both covered
- shopfloor dashboard: 'All Business Units' filter label -> 'All Locations'
- geenforce display dispatcher: startup sweep also matches the imaging
  installers' 'GE Aerospace Dashboard/Lobby' shortcuts by name
This commit is contained in:
cproudlock
2026-07-28 18:21:47 -04:00
parent 3a8df166cf
commit 9a2d0ccebb
4 changed files with 63 additions and 25 deletions

View File

@@ -124,23 +124,41 @@ def resolve_employee_display_name(sso):
None on any miss."""
if sso is None or not str(sso).isdigit():
return None
# 1. The employee directory (selfhosted table or external wjf_employees).
if _selfhosted():
emp = db.session.get(DirectoryEmployee, int(sso))
if emp:
return f'{emp.firstname} {emp.lastname}'.strip() or None
return None
name = f'{emp.firstname} {emp.lastname}'.strip()
if name:
return name
else:
try:
conn = employee_connection()
with conn.cursor() as cur:
cur.execute(
'SELECT First_Name, Last_Name FROM employees WHERE SSO = %s',
(int(sso),))
row = cur.fetchone()
conn.close()
if row:
first = row.get('First_Name') or ''
last = row.get('Last_Name') or ''
name = f'{first.strip()} {last.strip()}'.strip()
if name:
return name
except Exception:
pass
# 2. Fallback: a shopdb login account for this SSO (e.g. a user from another
# location not carried in the directory). Their name lives on the User
# record; GE usernames are the SSO. Photo still falls back to the GE mark.
try:
conn = employee_connection()
with conn.cursor() as cur:
cur.execute(
'SELECT First_Name, Last_Name FROM employees WHERE SSO = %s',
(int(sso),))
row = cur.fetchone()
conn.close()
if row:
first = row.get('First_Name') or ''
last = row.get('Last_Name') or ''
return f'{first.strip()} {last.strip()}'.strip() or None
from shopdb.core.models import User
user = User.query.filter_by(username=str(sso)).first()
if user:
name = f'{(user.firstname or "").strip()} {(user.lastname or "").strip()}'.strip()
if name:
return name
except Exception:
pass
return None