Improved naming of new setting and variables

This commit is contained in:
eeintech 2020-12-02 13:38:53 -05:00
parent 2bdd1305ed
commit de1dfdcc38
7 changed files with 30 additions and 30 deletions

View File

@ -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,
},

View File

@ -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 %}
<h4>{% trans "Stock Tracking Information" %}</h4>
<hr>
<!-- Check permissions and owner -->
{% 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 %}
<div id='table-toolbar'>
<div class='btn-group'>

View File

@ -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 %}
<div class='alert alert-block alert-info'>
@ -31,7 +31,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
</div>
{% 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 %}
<div class='alert alert-block alert-info'>
{% trans "You are not the owner of this item. This stock item cannot be edited." %}<br>
</div>
@ -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 %}
<h3>
{% trans "Stock Item" %}
@ -124,7 +124,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
</div>
<!-- Stock adjustment menu -->
<!-- Check permissions and owner -->
{% 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 %}
<div class='btn-group'>
<button id='stock-options' title='{% trans "Stock adjustment actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button>

View File

@ -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 %}
<div class='alert alert-block alert-info'>
{% trans "You are not in the list of owners of this location. This stock location cannot be edited." %}<br>
</div>
@ -27,7 +27,7 @@
<p>{% trans "All stock items" %}</p>
{% endif %}
<div class='btn-group action-buttons' role='group'>
{% 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 %}
<button class='btn btn-default' id='location-create' title='{% trans "Create new stock location" %}'>
<span class='fas fa-plus-circle icon-green'/>
@ -45,7 +45,7 @@
</ul>
</div>
<!-- Check permissions and owner -->
{% 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 %}
<div class='btn-group'>
<button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button>

View File

@ -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)'))

View File

@ -16,7 +16,7 @@
<table class='table table-striped table-condensed'>
<thead></thead>
<tbody>
{% include "InvenTree/settings/setting.html" with key="STOCK_OWNER" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" %}
</tbody>
</table>

View File

@ -1,7 +1,7 @@
{% load i18n %}
{% load inventree_extras %}
{% setting_object 'STOCK_OWNER' as owner_enable %}
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
<div id='button-toolbar'>
<div class='button-toolbar container-fluid' style='float: right;'>
@ -12,7 +12,7 @@
{% if read_only %}
{% else %}
<!-- Check permissions and owner -->
{% 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 %}
<button class="btn btn-success" id='item-create'>
<span class='fas fa-plus-circle'></span> {% trans "New Stock Item" %}