From 5625608bd01b9c250317fc7d4a21b8421314ea47 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Fri, 17 Jul 2026 11:16:04 -0400 Subject: [PATCH] Employees: external photo base URL is a setting External HR Picture values are relative paths; the resolver hardcoded /static/employees/ (which the SPA then mounts under the subpath, e.g. /ops/static/...), but sites like WJ serve those photos from the classic EmployeeDBAPP on another URL entirely. New setting employee_photo_base_url (blank keeps the old behavior; a full URL like https://host/EmployeeDBAPP/images/ passes through withBase untouched), declared in the plugin config schema. --- plugins/employees/api/routes.py | 12 ++++++++---- plugins/employees/plugin.py | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/employees/api/routes.py b/plugins/employees/api/routes.py index 0fb8f02..c7d44c2 100644 --- a/plugins/employees/api/routes.py +++ b/plugins/employees/api/routes.py @@ -43,9 +43,10 @@ EMPLOYEE_PHOTO_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.gif', '.webp'} # URL prefix a served upload resolves to (self-hosted mode). EMPLOYEE_PHOTO_URL_PREFIX = '/api/employees/photo/' -# URL prefix external HR relative picture paths resolve under. The HR employees -# table stores Picture as a relative path (e.g. 'Support/210009518.png') that -# the site serves from /static/employees/; this matches the shopfloor feed. +# Fallback URL prefix external HR relative picture paths resolve under when +# the employee_photo_base_url setting is unset. Sites whose photos live on +# another host (e.g. the classic EmployeeDBAPP) set the setting to a full URL +# such as https://host/EmployeeDBAPP/images/ instead. EMPLOYEE_PHOTO_STATIC_PREFIX = '/static/employees/' @@ -96,7 +97,10 @@ def _external_photo_url(picture): return None if text.startswith(('http://', 'https://', '/')): return text - return EMPLOYEE_PHOTO_STATIC_PREFIX + text + from shopdb.api import Setting + base = (Setting.get('employee_photo_base_url') or '').strip() \ + or EMPLOYEE_PHOTO_STATIC_PREFIX + return base.rstrip('/') + '/' + text.lstrip('/') def _hr_picture(sso): diff --git a/plugins/employees/plugin.py b/plugins/employees/plugin.py index 5f0a35b..dfdd1c3 100644 --- a/plugins/employees/plugin.py +++ b/plugins/employees/plugin.py @@ -79,6 +79,11 @@ class EmployeesPlugin(BasePlugin): """Employee directory DB connection. Host/name/user are settings the wizard can edit; the password stays in .env (emitted, not stored).""" return [ + {'key': 'employee_photo_base_url', 'label': 'Photo base URL', + 'type': 'text', 'secret': False, + 'help': 'Where external HR relative Picture paths resolve, e.g. ' + 'https://host/EmployeeDBAPP/images/. Blank = this ' + 'site\'s /static/employees/.'}, {'key': 'employee_db_host', 'label': 'Employee DB host', 'type': 'text', 'secret': False, 'default': 'localhost', 'help': 'This DB must expose an "employees" table or view with columns '