Refactor stock location view

This commit is contained in:
Oliver 2021-10-27 23:46:09 +11:00
parent 840187f577
commit a21959f54d
2 changed files with 120 additions and 137 deletions

View File

@ -7,50 +7,27 @@
{% include "stock/location_navbar.html" %} {% include "stock/location_navbar.html" %}
{% endblock %} {% endblock %}
{% block content %} {% block details_left %}
{% if location %}
<div class='panel panel-inventree'>
<div class='panel-heading'>
<h4> <h4>
{% if location %} {% trans "Stock Location" %}: {{ location.name }}
{{ location.name }}
{% if location %}
{% if user.is_staff and roles.stock_location.change %} {% if user.is_staff and roles.stock_location.change %}
<a href="{% url 'admin:stock_stocklocation_change' location.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a> <a href="{% url 'admin:stock_stocklocation_change' location.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% endif %} {% endif %}
</h3> </h4>
<p>{{ location.description }}</p>
{% else %} {% else %}
<h3>{% trans "Stock" %}</h3> <h4>
{% trans "Stock" %}
</h4>
<p>{% trans "All stock items" %}</p> <p>{% trans "All stock items" %}</p>
{% endif %} {% endif %}
{% else %}
{% trans "Stock" %}
{% endif %}
</h4>
</div>
<div class='panel-content'>
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}
{% authorized_owners location.owner as owners %}
{% if location and not user in owners 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>
{% endif %}
{% endif %}
<div class='row'>
<div class='col-sm-6'>
<div class='btn-group' role='group'> <div class='btn-group' role='group'>
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser or not location %} {% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser or not location %}
{% if roles.stock_location.add %} {% if roles.stock_location.add %}
<button class='btn btn-success' id='location-create' title='{% trans "Create new stock location" %}'> <button class='btn btn-success' id='location-create' type='button' title='{% trans "Create new stock location" %}'>
<span class='fas fa-plus-circle'/> <span class='fas fa-plus-circle'></span>
</button> </button>
{% endif %} {% endif %}
{% endif %} {% endif %}
@ -103,8 +80,21 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}
{% authorized_owners location.owner as owners %}
{% if location and not user in owners 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> </div>
<div class='col-sm-6'> {% endif %}
{% endif %}
{% endblock %}
{% block details_right %}
{% if location %} {% if location %}
<table class='table table-striped table-condensed'> <table class='table table-striped table-condensed'>
<col width='25'> <col width='25'>
@ -140,12 +130,9 @@
</tr> </tr>
</table> </table>
{% endif %} {% endif %}
</div> {% endblock %}
</div>
</div>
</div>
{% block location_content %} {% block page_content %}
<div class='panel panel-inventree panel-hidden' id='panel-stock'> <div class='panel panel-inventree panel-hidden' id='panel-stock'>
<div class='panel-heading'> <div class='panel-heading'>
@ -184,10 +171,6 @@
{% endblock %} {% endblock %}
</div>
{% endblock %}
{% block js_ready %} {% block js_ready %}
{{ block.super }} {{ block.super }}

View File

@ -1,4 +1,4 @@
{% extends "base.html" %} {% extends "page_base.html" %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% load inventree_extras %} {% load inventree_extras %}