From de1dfdcc386eed719797d947dba63fc26c44c03d Mon Sep 17 00:00:00 2001 From: eeintech Date: Wed, 2 Dec 2020 13:38:53 -0500 Subject: [PATCH] Improved naming of new setting and variables --- InvenTree/common/models.py | 6 ++-- InvenTree/stock/templates/stock/item.html | 4 +-- .../stock/templates/stock/item_base.html | 8 +++--- InvenTree/stock/templates/stock/location.html | 8 +++--- InvenTree/stock/views.py | 28 +++++++++---------- .../templates/InvenTree/settings/stock.html | 2 +- InvenTree/templates/stock_table.html | 4 +-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 7441614ec5..9de3726bb7 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -139,9 +139,9 @@ class InvenTreeSetting(models.Model): 'validator': bool, }, - 'STOCK_OWNER': { - 'name': _('Stock Owner Changes'), - 'description': _('Allow only owner of stock location and item to make changes'), + 'STOCK_OWNERSHIP_CONTROL': { + 'name': _('Stock Ownership Control'), + 'description': _('Enable ownership control over stock locations and items'), 'default': False, 'validator': bool, }, diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 92c02e8a3b..1082eef397 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -8,13 +8,13 @@ {% include "stock/tabs.html" with tab="tracking" %} -{% setting_object 'STOCK_OWNER' as owner_enable %} +{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}

{% trans "Stock Tracking Information" %}


-{% if owner_enable.value == "False" or owner_enable.value == "True" and item.owner == user %} +{% if owner_control.value == "False" or owner_control.value == "True" and item.owner == user %} {% if roles.stock.change and not item.is_building %}
diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index a8d775ef1a..e671c2d161 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -15,7 +15,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% block pre_content %} {% include 'stock/loc_link.html' with location=item.location %} -{% setting_object 'STOCK_OWNER' as owner_enable %} +{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %} {% if item.is_building %}
@@ -31,7 +31,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% endif %} -{% if owner_enable.value == "True" and not item.owner == user and not user.is_superuser %} +{% if owner_control.value == "True" and not item.owner == user and not user.is_superuser %}
{% trans "You are not the owner of this item. This stock item cannot be edited." %}
@@ -77,7 +77,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% block page_data %} -{% setting_object 'STOCK_OWNER' as owner_enable %} +{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}

{% trans "Stock Item" %} @@ -124,7 +124,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}

- {% if owner_enable.value == "False" or owner_enable.value == "True" and item.owner == user or user.is_superuser %} + {% if owner_control.value == "False" or owner_control.value == "True" and item.owner == user or user.is_superuser %} {% if roles.stock.change and not item.is_building %}
diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index d1fead76c3..6c47a697ca 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -4,9 +4,9 @@ {% load i18n %} {% block content %} -{% setting_object 'STOCK_OWNER' as owner_enable %} +{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %} -{% if location and owner_enable.value == "True" and not location.owner in user.groups.all and not user.is_superuser %} +{% if location and owner_control.value == "True" and not location.owner in user.groups.all and not user.is_superuser %}
{% trans "You are not in the list of owners of this location. This stock location cannot be edited." %}
@@ -27,7 +27,7 @@

{% trans "All stock items" %}

{% endif %}
- {% if owner_enable.value == "False" or owner_enable.value == "True" and location.owner in user.groups.all or user.is_superuser or not location %} + {% if owner_control.value == "False" or owner_control.value == "True" and location.owner in user.groups.all or user.is_superuser or not location %} {% if roles.stock.add %}
- {% if owner_enable.value == "False" or owner_enable.value == "True" and location.owner in user.groups.all or user.is_superuser %} + {% if owner_control.value == "False" or owner_control.value == "True" and location.owner in user.groups.all or user.is_superuser %} {% if roles.stock.change %}
diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index da2b5ea15b..56b37c15d9 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -146,8 +146,8 @@ class StockLocationEdit(AjaxUpdateView): form.fields['owner'].initial = location.parent.owner # Disable selection if stock ownership control is enabled - stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER') - if stock_owner_setting_enable: + stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL') + if stock_ownership_control: form.fields['owner'].disabled = True return form @@ -159,8 +159,8 @@ class StockLocationEdit(AjaxUpdateView): self.object = form.save() - stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER') - if self.object.get_children() and stock_owner_setting_enable: + stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL') + if self.object.get_children() and stock_ownership_control: for child in self.object.get_children(): child.owner = self.object.owner child.save() @@ -1330,8 +1330,8 @@ class StockItemEdit(AjaxUpdateView): location = item.location # Is ownership control enabled? - stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER') - if stock_owner_setting_enable and location: + stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL') + if stock_ownership_control and location: # Check if location has owner if location.owner: form.fields['owner'].queryset = User.objects.filter(groups=location.owner) @@ -1344,9 +1344,9 @@ class StockItemEdit(AjaxUpdateView): owner = form.cleaned_data.get('owner', None) # Is ownership control enabled? - stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER') + stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL') - if not owner and stock_owner_setting_enable: + if not owner and stock_ownership_control: form.add_error('owner', _('Owner is required (ownership control is enabled)')) @@ -1415,8 +1415,8 @@ class StockLocationCreate(AjaxCreateView): form.fields['owner'].initial = parent.owner # Disable selection if stock ownership control is enabled - stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER') - if stock_owner_setting_enable: + stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL') + if stock_ownership_control: form.fields['owner'].disabled = True except KeyError: pass @@ -1632,8 +1632,8 @@ class StockItemCreate(AjaxCreateView): pass # Is ownership control enabled? - stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER') - if stock_owner_setting_enable and location: + stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL') + if stock_ownership_control and location: # Check if location has owner if location.owner: queryset = User.objects.filter(groups=location.owner) @@ -1752,9 +1752,9 @@ class StockItemCreate(AjaxCreateView): ) # Is ownership control enabled? - stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER') + stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL') - if stock_owner_setting_enable: + if stock_ownership_control: # Check if owner is set if not owner: form.add_error('owner', _('Owner is required (ownership control is enabled)')) diff --git a/InvenTree/templates/InvenTree/settings/stock.html b/InvenTree/templates/InvenTree/settings/stock.html index f80a1c0926..ae5e17bf1a 100644 --- a/InvenTree/templates/InvenTree/settings/stock.html +++ b/InvenTree/templates/InvenTree/settings/stock.html @@ -16,7 +16,7 @@ - {% include "InvenTree/settings/setting.html" with key="STOCK_OWNER" %} + {% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" %}
diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index f954b1c97c..9746ff0aaa 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -1,7 +1,7 @@ {% load i18n %} {% load inventree_extras %} -{% setting_object 'STOCK_OWNER' as owner_enable %} +{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
@@ -12,7 +12,7 @@ {% if read_only %} {% else %} - {% if owner_enable.value == "False" or owner_enable.value == "True" and location.owner in user.groups.all or user.is_superuser %} + {% if owner_control.value == "False" or owner_control.value == "True" and location.owner in user.groups.all or user.is_superuser %} {% if roles.stock.add %}