From d49977bed3eb0c90871ca6cf82cc1f0f54e250e9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 15 Apr 2021 14:51:11 +0200 Subject: [PATCH 1/3] 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 %}


From 098ac0c46114481a7d54272c9c57e7a2f212a969 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 15 Apr 2021 14:52:08 +0200 Subject: [PATCH 2/3] using feature in views --- InvenTree/build/templates/build/allocate.html | 2 +- InvenTree/build/templates/build/build_base.html | 3 ++- InvenTree/build/templates/build/index.html | 2 +- InvenTree/company/templates/company/company_base.html | 2 +- InvenTree/company/templates/company/index.html | 3 ++- .../company/templates/company/supplier_part_base.html | 3 ++- InvenTree/order/templates/order/order_base.html | 2 +- InvenTree/order/templates/order/purchase_orders.html | 2 +- InvenTree/order/templates/order/sales_order_base.html | 2 +- InvenTree/order/templates/order/sales_orders.html | 2 +- InvenTree/part/templates/part/part_app_base.html | 7 ++++--- InvenTree/stock/templates/stock/item_base.html | 2 +- InvenTree/stock/templates/stock/stock_app_base.html | 5 +++-- InvenTree/templates/InvenTree/search.html | 3 ++- InvenTree/templates/InvenTree/settings/global.html | 1 + InvenTree/templates/InvenTree/settings/settings.html | 3 ++- InvenTree/templates/base.html | 2 +- InvenTree/templates/registration/logged_out.html | 7 ++++--- InvenTree/templates/registration/login.html | 5 +++-- .../templates/registration/password_reset_complete.html | 7 ++++--- .../templates/registration/password_reset_confirm.html | 7 ++++--- InvenTree/templates/registration/password_reset_done.html | 7 ++++--- InvenTree/templates/registration/password_reset_form.html | 7 ++++--- 23 files changed, 50 insertions(+), 36 deletions(-) diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index 6efde49308..1b66f17d0d 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -4,7 +4,7 @@ {% load inventree_extras %} {% block page_title %} -InvenTree | Allocate Parts +{% inventree_title %} | {% trans "Allocate Parts" %} {% endblock %} {% block menubar %} diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index a8e5e53377..39fb099eda 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -3,9 +3,10 @@ {% load static %} {% load i18n %} {% load status_codes %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Build Order" %} - {{ build }} +{% inventree_title %} | {% trans "Build Order" %} - {{ build }} {% endblock %} {% block pre_content %} diff --git a/InvenTree/build/templates/build/index.html b/InvenTree/build/templates/build/index.html index f710928ee7..fbed17bfa3 100644 --- a/InvenTree/build/templates/build/index.html +++ b/InvenTree/build/templates/build/index.html @@ -5,7 +5,7 @@ {% load i18n %} {% block page_title %} -InvenTree | {% trans "Build Orders" %} +{% inventree_title %} | {% trans "Build Orders" %} {% endblock %} {% block content %} diff --git a/InvenTree/company/templates/company/company_base.html b/InvenTree/company/templates/company/company_base.html index 236cc58981..1825132b0e 100644 --- a/InvenTree/company/templates/company/company_base.html +++ b/InvenTree/company/templates/company/company_base.html @@ -6,7 +6,7 @@ {% block page_title %} -InvenTree | {% trans "Company" %} - {{ company.name }} +{% inventree_title %} | {% trans "Company" %} - {{ company.name }} {% endblock %} diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index ca2fa619d9..3a3168f24e 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -2,9 +2,10 @@ {% load static %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Supplier List" %} +{% inventree_title %} | {% trans "Supplier List" %} {% endblock %} {% block content %} diff --git a/InvenTree/company/templates/company/supplier_part_base.html b/InvenTree/company/templates/company/supplier_part_base.html index 00de1a9fb3..ce61fcfcba 100644 --- a/InvenTree/company/templates/company/supplier_part_base.html +++ b/InvenTree/company/templates/company/supplier_part_base.html @@ -1,9 +1,10 @@ {% extends "two_column.html" %} {% load static %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Supplier Part" %} +{% inventree_title %} | {% trans "Supplier Part" %} {% endblock %} {% block thumbnail %} diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 130ebd4590..5dfc30796f 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -6,7 +6,7 @@ {% load status_codes %} {% block page_title %} -InvenTree | {% trans "Purchase Order" %} +{% inventree_title %} | {% trans "Purchase Order" %} {% endblock %} {% block thumbnail %} diff --git a/InvenTree/order/templates/order/purchase_orders.html b/InvenTree/order/templates/order/purchase_orders.html index 7256a1c499..9d15449abf 100644 --- a/InvenTree/order/templates/order/purchase_orders.html +++ b/InvenTree/order/templates/order/purchase_orders.html @@ -5,7 +5,7 @@ {% load i18n %} {% block page_title %} -InvenTree | {% trans "Purchase Orders" %} +{% inventree_title %} | {% trans "Purchase Orders" %} {% endblock %} {% block content %} diff --git a/InvenTree/order/templates/order/sales_order_base.html b/InvenTree/order/templates/order/sales_order_base.html index dfab8d1ae7..f0a71b8fec 100644 --- a/InvenTree/order/templates/order/sales_order_base.html +++ b/InvenTree/order/templates/order/sales_order_base.html @@ -6,7 +6,7 @@ {% load status_codes %} {% block page_title %} -InvenTree | {% trans "Sales Order" %} +{% inventree_title %} | {% trans "Sales Order" %} {% endblock %} {% block pre_content %} diff --git a/InvenTree/order/templates/order/sales_orders.html b/InvenTree/order/templates/order/sales_orders.html index bcaf6a019c..8ae538ffce 100644 --- a/InvenTree/order/templates/order/sales_orders.html +++ b/InvenTree/order/templates/order/sales_orders.html @@ -5,7 +5,7 @@ {% load i18n %} {% block page_title %} -InvenTree | {% trans "Sales Orders" %} +{% inventree_title %} | {% trans "Sales Orders" %} {% endblock %} {% block content %} diff --git a/InvenTree/part/templates/part/part_app_base.html b/InvenTree/part/templates/part/part_app_base.html index 94773f1e79..b3bd862fbd 100644 --- a/InvenTree/part/templates/part/part_app_base.html +++ b/InvenTree/part/templates/part/part_app_base.html @@ -1,14 +1,15 @@ {% extends "base.html" %} {% load static %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} {% if part %} -InvenTree | {% trans "Part" %} - {{ part.full_name }} +{% inventree_title %} | {% trans "Part" %} - {{ part.full_name }} {% elif category %} -InvenTree | {% trans "Part Category" %} - {{ category }} +{% inventree_title %} | {% trans "Part Category" %} - {{ category }} {% else %} -InvenTree | {% trans "Part List" %} +{% inventree_title %} | {% trans "Part List" %} {% endif %} {% endblock %} diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 04518a0c65..7294a17743 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -5,7 +5,7 @@ {% load i18n %} {% block page_title %} -InvenTree | {% trans "Stock Item" %} - {{ item }} +{% inventree_title %} | {% trans "Stock Item" %} - {{ item }} {% endblock %} {% block sidenav %} diff --git a/InvenTree/stock/templates/stock/stock_app_base.html b/InvenTree/stock/templates/stock/stock_app_base.html index dfe32c767d..209aea3956 100644 --- a/InvenTree/stock/templates/stock/stock_app_base.html +++ b/InvenTree/stock/templates/stock/stock_app_base.html @@ -1,12 +1,13 @@ {% extends "base.html" %} {% load static %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} {% if location %} -InvenTree | {% trans "Stock Location" %} - {{ location }} +{% inventree_title %} | {% trans "Stock Location" %} - {{ location }} {% else %} -InvenTree | {% trans "Stock" %} +{% inventree_title %} | {% trans "Stock" %} {% endif %} {% endblock %} diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index b65ec00c00..efa5127385 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -2,9 +2,10 @@ {% load static %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Search Results" %} +{% inventree_title %} | {% trans "Search Results" %} {% endblock %} {% block content %} diff --git a/InvenTree/templates/InvenTree/settings/global.html b/InvenTree/templates/InvenTree/settings/global.html index c234bd1379..a0347490d0 100644 --- a/InvenTree/templates/InvenTree/settings/global.html +++ b/InvenTree/templates/InvenTree/settings/global.html @@ -16,6 +16,7 @@ {% include "InvenTree/settings/header.html" %} {% 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_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_DEFAULT_CURRENCY" icon="fa-dollar-sign" %} diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index fe9fd00e53..f63860012c 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -2,9 +2,10 @@ {% load i18n %} {% load static %} +{% load inventree_extras %} {% block page_title %} -InvenTree | {% trans "Settings" %} +{% inventree_title %} | {% trans "Settings" %} {% endblock %} {% block content %} diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index 140971a8ce..8ccf691ef5 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -60,7 +60,7 @@ {% block page_title %} -InvenTree +{% inventree_title %} {% endblock %} diff --git a/InvenTree/templates/registration/logged_out.html b/InvenTree/templates/registration/logged_out.html index b23ba001e2..f5882c7ff1 100644 --- a/InvenTree/templates/registration/logged_out.html +++ b/InvenTree/templates/registration/logged_out.html @@ -1,6 +1,7 @@ {% load static %} {% load i18n %} -{% load crispy_forms_tags %} +{% load crispy_forms_tags %} +{% load inventree_extras %} @@ -29,7 +30,7 @@ - InvenTree + {% inventree_title %} @@ -42,7 +43,7 @@

diff --git a/InvenTree/templates/registration/login.html b/InvenTree/templates/registration/login.html index 37eda9a103..2032f62773 100644 --- a/InvenTree/templates/registration/login.html +++ b/InvenTree/templates/registration/login.html @@ -1,5 +1,6 @@ {% load static %} {% load i18n %} +{% load inventree_extras %} @@ -28,7 +29,7 @@ - InvenTree + {% inventree_title %} @@ -44,7 +45,7 @@

diff --git a/InvenTree/templates/registration/password_reset_complete.html b/InvenTree/templates/registration/password_reset_complete.html index 7fc83d85ba..a941aa6fee 100644 --- a/InvenTree/templates/registration/password_reset_complete.html +++ b/InvenTree/templates/registration/password_reset_complete.html @@ -1,6 +1,7 @@ {% load static %} {% load i18n %} -{% load crispy_forms_tags %} +{% load crispy_forms_tags %} +{% load inventree_extras %} @@ -29,7 +30,7 @@ - InvenTree + {% inventree_title %} @@ -42,7 +43,7 @@

diff --git a/InvenTree/templates/registration/password_reset_confirm.html b/InvenTree/templates/registration/password_reset_confirm.html index 455baea698..dd52cb135f 100644 --- a/InvenTree/templates/registration/password_reset_confirm.html +++ b/InvenTree/templates/registration/password_reset_confirm.html @@ -1,6 +1,7 @@ {% load static %} {% load i18n %} -{% load crispy_forms_tags %} +{% load crispy_forms_tags %} +{% load inventree_extras %} @@ -29,7 +30,7 @@ - InvenTree + {% inventree_title %} @@ -42,7 +43,7 @@

diff --git a/InvenTree/templates/registration/password_reset_done.html b/InvenTree/templates/registration/password_reset_done.html index 04e0aec69b..17a786f2a4 100644 --- a/InvenTree/templates/registration/password_reset_done.html +++ b/InvenTree/templates/registration/password_reset_done.html @@ -1,6 +1,7 @@ {% load static %} {% load i18n %} -{% load crispy_forms_tags %} +{% load crispy_forms_tags %} +{% load inventree_extras %} @@ -29,7 +30,7 @@ - InvenTree + {% inventree_title %} @@ -42,7 +43,7 @@

diff --git a/InvenTree/templates/registration/password_reset_form.html b/InvenTree/templates/registration/password_reset_form.html index dabada5651..a2c241b7d7 100644 --- a/InvenTree/templates/registration/password_reset_form.html +++ b/InvenTree/templates/registration/password_reset_form.html @@ -1,6 +1,7 @@ {% load static %} {% load i18n %} -{% load crispy_forms_tags %} +{% load crispy_forms_tags %} +{% load inventree_extras %} @@ -29,7 +30,7 @@ - InvenTree + {% inventree_title %} @@ -42,7 +43,7 @@

From e668577d975c18550e9f1d17c4283239b4068364 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 18 Apr 2021 12:31:17 +0200 Subject: [PATCH 3/3] fix as noted in #1481 --- InvenTree/common/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 2f82df7d92..bc2ca4214b 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -59,8 +59,8 @@ class InvenTreeSetting(models.Model): }, 'INVENTREE_INSTANCE_TITLE': { - 'name': _('Use Instance Name'), - 'description': _('Use the instance name in the Titel-Bar'), + 'name': _('Use instance name'), + 'description': _('Use the instance name in the title-bar'), 'validator': bool, 'default': False, },