From d49977bed3eb0c90871ca6cf82cc1f0f54e250e9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 15 Apr 2021 14:51:11 +0200 Subject: [PATCH] initial implementation as described in #1463 --- InvenTree/InvenTree/version.py | 8 ++++++++ InvenTree/common/models.py | 7 +++++++ InvenTree/part/templatetags/inventree_extras.py | 6 ++++++ InvenTree/templates/InvenTree/index.html | 5 +++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index b79323e1e7..6c0a524559 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -19,6 +19,14 @@ def inventreeInstanceName(): return common.models.InvenTreeSetting.get_setting("INVENTREE_INSTANCE", "") +def inventreeInstanceTitle(): + """ Returns the InstanceTitle for the current database """ + if common.models.InvenTreeSetting.get_setting("INVENTREE_INSTANCE_TITLE", False): + return common.models.InvenTreeSetting.get_setting("INVENTREE_INSTANCE", "") + else: + return 'InvenTree' + + def inventreeVersion(): """ Returns the InvenTree version string """ return INVENTREE_SW_VERSION diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 79580aabd9..2f82df7d92 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -58,6 +58,13 @@ class InvenTreeSetting(models.Model): 'description': _('String descriptor for the server instance'), }, + 'INVENTREE_INSTANCE_TITLE': { + 'name': _('Use Instance Name'), + 'description': _('Use the instance name in the Titel-Bar'), + 'validator': bool, + 'default': False, + }, + 'INVENTREE_COMPANY_NAME': { 'name': _('Company name'), 'description': _('Internal company name'), diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index c0dc15c2b0..868c09696a 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -71,6 +71,12 @@ def inventree_instance_name(*args, **kwargs): return version.inventreeInstanceName() +@register.simple_tag() +def inventree_title(*args, **kwargs): + """ Return the title for the current instance - respecting the settings """ + return version.inventreeInstanceTitle() + + @register.simple_tag() def inventree_version(*args, **kwargs): """ Return InvenTree version string """ diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index f7154e5fbb..9b18e2d94c 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -2,12 +2,13 @@ {% load i18n %} {% load static %} {% load inventree_extras %} + {% block page_title %} -InvenTree | {% trans "Index" %} +{% inventree_title %} | {% trans "Index" %} {% endblock %} {% block content %} -

InvenTree

+

{% inventree_title %}