From 1127bf2497f95c9ad3937438d84cd1a621be7f67 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 24 Apr 2022 01:02:41 +0200 Subject: [PATCH] make it possible to resitrict the about modal --- InvenTree/common/models.py | 7 +++++++ InvenTree/part/templatetags/inventree_extras.py | 8 ++++++++ InvenTree/templates/InvenTree/settings/global.html | 1 + InvenTree/templates/base.html | 3 ++- InvenTree/templates/navbar.html | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index bb7de56e99..d0ca4636a0 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -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'), diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 0400b54ebd..ad23487a83 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -166,6 +166,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 """ 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/base.html b/InvenTree/templates/base.html index 0bca5cc0f1..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" %} diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index d687300eb4..3af7fe481f 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -7,6 +7,7 @@ {% 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 %}