diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 04c9a9bc19..6e88fe8375 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -25,6 +25,7 @@ import moneyed import yaml from django.utils.translation import gettext_lazy as _ from django.contrib.messages import constants as messages +from django.core.files.storage import default_storage import django.conf.locale from .config import get_base_dir, get_config_file, get_plugin_file, get_setting @@ -913,3 +914,20 @@ PLUGIN_TESTING = get_setting('PLUGIN_TESTING', TESTING) # are plugins beeing te PLUGIN_TESTING_SETUP = get_setting('PLUGIN_TESTING_SETUP', False) # load plugins from setup hooks in testing? PLUGIN_RETRY = get_setting('PLUGIN_RETRY', 5) # how often should plugin loading be tried? PLUGIN_FILE_CHECKED = False # Was the plugin file checked? + +# user interface customization values +CUSTOMIZE = get_setting( + 'INVENTREE_CUSTOMIZE', + CONFIG.get('customize', {}), + {} +) + +CUSTOM_LOGO = get_setting( + 'INVENTREE_CUSTOM_LOGO', + CUSTOMIZE.get('logo', False) +) + +# check that the logo-file exsists in media +if CUSTOM_LOGO and not default_storage.exists(CUSTOM_LOGO): + CUSTOM_LOGO = False + logger.warning("The custom logo file could not be found in the default media storage") diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 8bd100dcc9..f1cd8bc09a 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -684,7 +684,7 @@ class InvenTreeSetting(BaseInvenTreeSetting): }, 'INVENTREE_INSTANCE': { - 'name': _('InvenTree Instance Name'), + 'name': _('Server Instance Name'), 'default': 'InvenTree server', 'description': _('String descriptor for the server instance'), }, @@ -696,6 +696,13 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'default': False, }, + 'INVENTREE_RESTRICT_ABOUT': { + 'name': _('Restrict showing `about`'), + 'description': _('Show the `about` modal only to superusers'), + 'validator': bool, + 'default': False, + }, + 'INVENTREE_COMPANY_NAME': { 'name': _('Company name'), 'description': _('Internal company name'), @@ -1353,7 +1360,7 @@ class InvenTreeUserSetting(BaseInvenTreeSetting): 'STICKY_HEADER': { 'name': _('Fixed Navbar'), - 'description': _('InvenTree navbar position is fixed to the top of the screen'), + 'description': _('The navbar position is fixed to the top of the screen'), 'default': False, 'validator': bool, }, diff --git a/InvenTree/common/tests.py b/InvenTree/common/tests.py index 77a4f1a12d..c3ce4f9e51 100644 --- a/InvenTree/common/tests.py +++ b/InvenTree/common/tests.py @@ -63,8 +63,8 @@ class SettingsTest(TestCase): report_test_obj = InvenTreeSetting.get_setting_object('REPORT_ENABLE_TEST_REPORT') # check settings base fields - self.assertEqual(instance_obj.name, 'InvenTree Instance Name') - self.assertEqual(instance_obj.get_setting_name(instance_ref), 'InvenTree Instance Name') + self.assertEqual(instance_obj.name, 'Server Instance Name') + self.assertEqual(instance_obj.get_setting_name(instance_ref), 'Server Instance Name') self.assertEqual(instance_obj.description, 'String descriptor for the server instance') self.assertEqual(instance_obj.get_setting_description(instance_ref), 'String descriptor for the server instance') diff --git a/InvenTree/company/templates/company/manufacturer_part.html b/InvenTree/company/templates/company/manufacturer_part.html index 84e8016a59..fb33128a77 100644 --- a/InvenTree/company/templates/company/manufacturer_part.html +++ b/InvenTree/company/templates/company/manufacturer_part.html @@ -1,9 +1,10 @@ {% extends "page_base.html" %} {% load static %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Manufacturer Part" %} +{% inventree_title %} | {% trans "Manufacturer Part" %} {% endblock %} {% block sidebar %} diff --git a/InvenTree/config_template.yaml b/InvenTree/config_template.yaml index 65dd20d3e8..b9d14c4d4b 100644 --- a/InvenTree/config_template.yaml +++ b/InvenTree/config_template.yaml @@ -186,3 +186,10 @@ static_root: '/home/inventree/data/static' # KEYCLOAK_URL: 'https://keycloak.custom/auth' # KEYCLOAK_REALM: 'master' +# Customization options +# Add custom messages to the login page or main interface navbar or exchange the logo +# Use environment variable INVENTREE_CUSTOMIZE or INVENTREE_CUSTOM_LOGO +# customize: +# login_message: InvenTree demo instance - Click here for login details +# navbar_message:
InvenTree demo mode
+# logo: logo.png diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 08fa8ce583..5701658087 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -18,7 +18,8 @@ from django.conf import settings as djangosettings from django import template from django.urls import reverse from django.utils.safestring import mark_safe -from django.templatetags.static import StaticNode +from django.templatetags.static import StaticNode, static +from django.core.files.storage import default_storage from InvenTree import version, settings @@ -166,6 +167,14 @@ def inventree_demo_mode(*args, **kwargs): return djangosettings.DEMO_MODE +@register.simple_tag() +def inventree_show_about(user, *args, **kwargs): + """ Return True if the about modal should be shown """ + if InvenTreeSetting.get_setting('INVENTREE_RESTRICT_ABOUT') and not user.is_superuser: + return False + return True + + @register.simple_tag() def inventree_docker_mode(*args, **kwargs): """ Return True if the server is running as a Docker image """ @@ -220,8 +229,13 @@ def python_version(*args, **kwargs): @register.simple_tag() -def inventree_version(*args, **kwargs): +def inventree_version(shortstring=False, *args, **kwargs): """ Return InvenTree version string """ + if shortstring: + return _("{title} v{version}".format( + title=version.inventreeInstanceTitle(), + version=version.inventreeVersion() + )) return version.inventreeVersion() @@ -512,6 +526,22 @@ def mail_configured(): return bool(settings.EMAIL_HOST) +@register.simple_tag() +def inventree_customize(reference, *args, **kwargs): + """ Return customization values for the user interface """ + + return djangosettings.CUSTOMIZE.get(reference, '') + + +@register.simple_tag() +def inventree_logo(*args, **kwargs): + """ Return the path to the logo-file """ + + if settings.CUSTOM_LOGO: + return default_storage.url(settings.CUSTOM_LOGO) + return static('img/inventree.png') + + class I18nStaticNode(StaticNode): """ custom StaticNode diff --git a/InvenTree/report/templates/report/inventree_po_report.html b/InvenTree/report/templates/report/inventree_po_report.html index f999644c2e..d1cae75c3b 100644 --- a/InvenTree/report/templates/report/inventree_po_report.html +++ b/InvenTree/report/templates/report/inventree_po_report.html @@ -15,7 +15,7 @@ content: "v{{report_revision}} - {{ date.isoformat }}"; {% endblock %} {% block bottom_center %} -content: "InvenTree v{% inventree_version %}"; +content: "{% inventree_version shortstring=True %}"; {% endblock %} {% block style %} diff --git a/InvenTree/report/templates/report/inventree_so_report.html b/InvenTree/report/templates/report/inventree_so_report.html index 255f0c6a50..5cb4900719 100644 --- a/InvenTree/report/templates/report/inventree_so_report.html +++ b/InvenTree/report/templates/report/inventree_so_report.html @@ -16,7 +16,7 @@ content: "v{{report_revision}} - {{ date.isoformat }}"; {% endblock %} {% block bottom_center %} -content: "InvenTree v{% inventree_version %}"; +content: "{% inventree_version shortstring=True %}"; {% endblock %} {% block style %} diff --git a/InvenTree/report/templates/report/inventree_test_report_base.html b/InvenTree/report/templates/report/inventree_test_report_base.html index d702973c30..73ee55c680 100644 --- a/InvenTree/report/templates/report/inventree_test_report_base.html +++ b/InvenTree/report/templates/report/inventree_test_report_base.html @@ -14,7 +14,7 @@ content: "{{ date.isoformat }}"; {% endblock %} {% block bottom_center %} -content: "InvenTree v{% inventree_version %}"; +content: "{% inventree_version shortstring=True %}"; {% endblock %} {% block top_center %} diff --git a/InvenTree/templates/403.html b/InvenTree/templates/403.html index 372bd9fe27..4ee8367d9c 100644 --- a/InvenTree/templates/403.html +++ b/InvenTree/templates/403.html @@ -1,8 +1,9 @@ {% extends "base.html" %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Permission Denied" %} +{% inventree_title %} | {% trans "Permission Denied" %} {% endblock %} {% block content %} diff --git a/InvenTree/templates/404.html b/InvenTree/templates/404.html index 3cb6464d99..aae55031f3 100644 --- a/InvenTree/templates/404.html +++ b/InvenTree/templates/404.html @@ -1,8 +1,9 @@ {% extends "base.html" %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Page Not Found" %} +{% inventree_title %} | {% trans "Page Not Found" %} {% endblock %} {% block content %} diff --git a/InvenTree/templates/500.html b/InvenTree/templates/500.html index 3fab6c0a17..f50a5ea6fe 100644 --- a/InvenTree/templates/500.html +++ b/InvenTree/templates/500.html @@ -1,8 +1,9 @@ {% extends "base.html" %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Internal Server Error" %} +{% inventree_title %} | {% trans "Internal Server Error" %} {% endblock %} {% block content %} @@ -11,7 +12,7 @@ InvenTree | {% trans "Internal Server Error" %}

{% trans "Internal Server Error" %}

- {% trans "The InvenTree server raised an internal error" %}
+ {% blocktrans %}The {{ inventree_title }} server raised an internal error{% endblocktrans %}
{% trans "Refer to the error log in the admin interface for further details" %}
diff --git a/InvenTree/templates/503.html b/InvenTree/templates/503.html index fbee60c694..7b5b25d611 100644 --- a/InvenTree/templates/503.html +++ b/InvenTree/templates/503.html @@ -30,7 +30,7 @@
- + {% include "spacer.html" %}

{% block body_title %}{% trans 'Site is in Maintenance' %}{% endblock %}

diff --git a/InvenTree/templates/InvenTree/settings/global.html b/InvenTree/templates/InvenTree/settings/global.html index 60ae84f001..4d36d59369 100644 --- a/InvenTree/templates/InvenTree/settings/global.html +++ b/InvenTree/templates/InvenTree/settings/global.html @@ -15,6 +15,7 @@ {% include "InvenTree/settings/setting.html" with key="INVENTREE_INSTANCE" icon="fa-info-circle" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_INSTANCE_TITLE" icon="fa-info-circle" %} + {% include "InvenTree/settings/setting.html" with key="INVENTREE_RESTRICT_ABOUT" icon="fa-info-circle" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_BASE_URL" icon="fa-globe" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_COMPANY_NAME" icon="fa-building" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_DOWNLOAD_FROM_URL" icon="fa-cloud-download-alt" %} diff --git a/InvenTree/templates/InvenTree/settings/plugin.html b/InvenTree/templates/InvenTree/settings/plugin.html index 2366096b87..94a166c84a 100644 --- a/InvenTree/templates/InvenTree/settings/plugin.html +++ b/InvenTree/templates/InvenTree/settings/plugin.html @@ -13,7 +13,7 @@ {% block content %}
- {% trans "Changing the settings below require you to immediatly restart InvenTree. Do not change this while under active usage." %} + {% trans "Changing the settings below require you to immediatly restart the server. Do not change this while under active usage." %}
diff --git a/InvenTree/templates/InvenTree/settings/plugin_settings.html b/InvenTree/templates/InvenTree/settings/plugin_settings.html index 9c5fa2d7c0..79150ec879 100644 --- a/InvenTree/templates/InvenTree/settings/plugin_settings.html +++ b/InvenTree/templates/InvenTree/settings/plugin_settings.html @@ -85,7 +85,7 @@ {% if plugin.is_package %} {% trans "This plugin was installed as a package" %} {% else %} - {% trans "This plugin was found in a local InvenTree path" %} + {% trans "This plugin was found in a local server path" %} {% endif %} diff --git a/InvenTree/templates/InvenTree/settings/user_display.html b/InvenTree/templates/InvenTree/settings/user_display.html index f5e74b04c1..1f52c095ac 100644 --- a/InvenTree/templates/InvenTree/settings/user_display.html +++ b/InvenTree/templates/InvenTree/settings/user_display.html @@ -101,7 +101,7 @@

{% trans "Help the translation efforts!" %}

-

{% blocktrans with link="https://crowdin.com/project/inventree" %}Native language translation of the InvenTree web application is community contributed via crowdin. Contributions are welcomed and encouraged.{% endblocktrans %}

+

{% blocktrans with link="https://crowdin.com/project/inventree" %}Native language translation of the web application is community contributed via crowdin. Contributions are welcomed and encouraged.{% endblocktrans %}

diff --git a/InvenTree/templates/account/base.html b/InvenTree/templates/account/base.html index 6c54faac67..9a68f7ba31 100644 --- a/InvenTree/templates/account/base.html +++ b/InvenTree/templates/account/base.html @@ -67,7 +67,7 @@
- + {% include "spacer.html" %}

{% inventree_title %}

@@ -89,7 +89,7 @@ - + diff --git a/InvenTree/templates/account/login.html b/InvenTree/templates/account/login.html index 6e62560bfa..fcdd08a23c 100644 --- a/InvenTree/templates/account/login.html +++ b/InvenTree/templates/account/login.html @@ -10,6 +10,7 @@ {% settings_value 'LOGIN_ENABLE_REG' as enable_reg %} {% settings_value 'LOGIN_ENABLE_PWD_FORGOT' as enable_pwd_forgot %} {% settings_value 'LOGIN_ENABLE_SSO' as enable_sso %} +{% inventree_customize 'login_message' as login_message %} {% mail_configured as mail_conf %} {% inventree_demo_mode as demo %} @@ -35,19 +36,15 @@ for a account and sign in below:{% endblocktrans %}

{% endif %}
+ {% if login_message %} +
{{ login_message }}
+ {% endif %}
{% if mail_conf and enable_pwd_forgot and not demo %} {% trans "Forgot Password?" %} {% endif %} - {% if demo %} -

-

- {% trans "InvenTree demo instance" %} - {% trans "Click here for login details" %} -
-

- {% endif %} {% if enable_sso %} diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index 0739b42b6e..0188ecefa5 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -7,6 +7,7 @@ {% settings_value "REPORT_ENABLE" as report_enabled %} {% settings_value "SERVER_RESTART_REQUIRED" as server_restart_required %} {% settings_value "LABEL_ENABLE" with user=user as labels_enabled %} +{% inventree_show_about user as show_about %} {% inventree_demo_mode as demo_mode %} @@ -130,7 +131,7 @@
{% include 'modals.html' %} - {% include 'about.html' %} + {% if show_about %}{% include 'about.html' %}{% endif %} {% include "notifications.html" %} {% include "search.html" %} @@ -166,7 +167,7 @@ - + diff --git a/InvenTree/templates/email/email.html b/InvenTree/templates/email/email.html index 97e9a40f37..0b3c944da4 100644 --- a/InvenTree/templates/email/email.html +++ b/InvenTree/templates/email/email.html @@ -32,7 +32,7 @@ {% block footer_prefix %} {% endblock %} -

{% trans "InvenTree version" %}: {% inventree_version %} - inventree.readthedocs.io

+

{% inventree_version shortstring=True %} - readthedocs.io

{% block footer_suffix %} {% endblock %} diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index d687300eb4..d7d70db59f 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -7,11 +7,13 @@ {% settings_value 'STICKY_HEADER' user=request.user as sticky %} {% navigation_enabled as plugin_nav %} {% inventree_demo_mode as demo %} +{% inventree_show_about user as show_about %} +{% inventree_customize 'navbar_message' as navbar_message %}