From 9ba20100de548f2b1cd6662b883719ae02fc5edc Mon Sep 17 00:00:00 2001 From: Cam Proudlock Date: Fri, 17 Jul 2026 11:16:05 -0400 Subject: [PATCH] Employees: external photo base URL is a setting External HR Picture values are relative paths; the resolver hardcoded /static/employees/, but sites can serve photos from another host. New employee_photo_base_url setting; blank keeps the old behavior. --- 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 0fb8f024..c7d44c20 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 5f0a35bd..dfdd1c3b 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 '