diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 51dc08bd47..e1ea93c885 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -265,6 +265,20 @@ def getLogoImage(as_file=False, custom=True): return getStaticUrl('img/inventree.png') +def getSplashScren(custom=True): + """Return the InvenTree splash screen, or a custom splash if available""" + + static_storage = StaticFilesStorage() + + if custom and settings.CUSTOM_SPLASH: + + if static_storage.exists(settings.CUSTOM_SPLASH): + return static_storage.url(settings.CUSTOM_SPLASH) + + # No custom splash screen + return static_storage.url("img/inventree_splash.jpg") + + def TestIfImageURL(url): """Test if an image URL (or filename) looks like a valid image format. diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 3e2c907c22..2d4b898f74 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -820,7 +820,7 @@ PLUGIN_FILE_CHECKED = False # Was the plugin file checked? # User interface customization values CUSTOMIZE = get_setting('INVENTREE_CUSTOMIZE', 'customize', {}) -CUSTOM_LOGO = get_setting('INVENTREE_CUSTOM_LOGO', 'customize.logo', None) +static_storage = StaticFilesStorage() """ Check for the existence of a 'custom logo' file: @@ -828,9 +828,9 @@ Check for the existence of a 'custom logo' file: - Check the 'media' directory (legacy) """ -if CUSTOM_LOGO: - static_storage = StaticFilesStorage() +CUSTOM_LOGO = get_setting('INVENTREE_CUSTOM_LOGO', 'customize.logo', None) +if CUSTOM_LOGO: if static_storage.exists(CUSTOM_LOGO): logger.info(f"Loading custom logo from static directory: {CUSTOM_LOGO}") elif default_storage.exists(CUSTOM_LOGO): @@ -839,8 +839,18 @@ if CUSTOM_LOGO: logger.warning(f"The custom logo file '{CUSTOM_LOGO}' could not be found in the static or media directories") CUSTOM_LOGO = False +# Check for a custom splash screen +CUSTOM_SPLASH = get_setting('INVENTREE_CUSTOM_SPLASH', 'customize.splash', None) + +if CUSTOM_SPLASH: + if static_storage.exists(CUSTOM_SPLASH): + logger.info(f"Loading custom splash screen from static directory: {CUSTOM_SPLASH}") + else: + logger.warning(f"The custom splash screen '{CUSTOM_SPLASH}' could not be found in the static directory") + CUSTOM_SPLASH = False + if DEBUG: logger.info("InvenTree running with DEBUG enabled") -logger.debug(f"MEDIA_ROOT: '{MEDIA_ROOT}'") -logger.debug(f"STATIC_ROOT: '{STATIC_ROOT}'") +logger.info(f"MEDIA_ROOT: '{MEDIA_ROOT}'") +logger.info(f"STATIC_ROOT: '{STATIC_ROOT}'") diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 96409dc9a1..0d6b07e9ff 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -19,8 +19,8 @@ main { } .login-screen { - background: url(/static/img/paper_splash.jpg) no-repeat center fixed; background-size: cover; + background-position: center; height: 100vh; font-family: 'Numans', sans-serif; color: #eee; diff --git a/InvenTree/InvenTree/static/img/paper_splash.jpg b/InvenTree/InvenTree/static/img/inventree_splash.jpg similarity index 100% rename from InvenTree/InvenTree/static/img/paper_splash.jpg rename to InvenTree/InvenTree/static/img/inventree_splash.jpg diff --git a/InvenTree/config_template.yaml b/InvenTree/config_template.yaml index aa5d715d04..549f2f011c 100644 --- a/InvenTree/config_template.yaml +++ b/InvenTree/config_template.yaml @@ -188,5 +188,6 @@ remote_login_header: REMOTE_USER # login_message: InvenTree demo instance - Click here for login details # navbar_message:
InvenTree demo mode
# logo: logo.png +# splash: splash_screen.jpg # hide_admin_link: true # hide_password_reset: true diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 4516f17e5e..6116acd327 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -195,7 +195,7 @@ def inventree_title(*args, **kwargs): @register.simple_tag() def inventree_logo(**kwargs): - """Return the InvenTree logo, *or* a custom logo if the user has uploaded one. + """Return the InvenTree logo, *or* a custom logo if the user has provided one. Returns a path to an image file, which can be rendered in the web interface """ @@ -203,6 +203,13 @@ def inventree_logo(**kwargs): return InvenTree.helpers.getLogoImage(**kwargs) +@register.simple_tag() +def inventree_splash(**kwargs): + """Return the URL for the InvenTree splash screen, *or* a custom screen if the user has provided one.""" + + return InvenTree.helpers.getSplashScren(**kwargs) + + @register.simple_tag() def inventree_base_url(*args, **kwargs): """Return the INVENTREE_BASE_URL setting.""" diff --git a/InvenTree/templates/account/base.html b/InvenTree/templates/account/base.html index 4ac646b717..518ab0798b 100644 --- a/InvenTree/templates/account/base.html +++ b/InvenTree/templates/account/base.html @@ -49,10 +49,8 @@ {% endblock %} - - + +