Hide edit buttons if user is not staff

This commit is contained in:
Johannes Schriewer 2020-12-22 03:47:35 +01:00
parent 926207564e
commit d5388a0fb4
4 changed files with 36 additions and 14 deletions

View file

@ -11,27 +11,34 @@
{% for a in area.area_related.all %} {% for a in area.area_related.all %}
<li> <li>
<a href="{% url 'area-detail' a.id %}" title="{{ a.description }}">{{ a.name }}</a> <a href="{% url 'area-detail' a.id %}" title="{{ a.description }}">{{ a.name }}</a>
{% if user.is_staff %}
<a class="edit" href="{% url "admin:inventory_area_change" object_id=area.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a> <a class="edit" href="{% url "admin:inventory_area_change" object_id=area.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
{% endif %}
</li> </li>
{% empty %} {% empty %}
<li>No areas defined</li> <li>No areas defined</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% if user.is_staff %}
<p><a href="{% url "admin:inventory_area_add" %}?container={{ area.id }}&index=0">Create new area...</a></p> <p><a href="{% url "admin:inventory_area_add" %}?container={{ area.id }}&index=0">Create new area...</a></p>
{% endif %}
<h3>Boxes</h3> <h3>Boxes</h3>
<ul> <ul>
{% for box in area.box_related.all %} {% for box in area.box_related.all %}
<li> <li>
<a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }} ({{ box.layout.name }})</a> <a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }} ({{ box.layout.name }})</a>
{% if user.is_staff %}
<a class="edit" href="{% url "admin:inventory_box_change" object_id=box.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a> <a class="edit" href="{% url "admin:inventory_box_change" object_id=box.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
{% endif %}
</li> </li>
{% empty %} {% empty %}
<li>No boxes defined</li> <li>No boxes defined</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% if user.is_staff %}
<p><a href="{% url "admin:inventory_box_add" %}?container={{ area.id }}&index=0">Create new container...</a></p> <p><a href="{% url "admin:inventory_box_add" %}?container={{ area.id }}&index=0">Create new container...</a></p>
{% endif %}
{% endblock %} {% endblock %}

View file

@ -16,7 +16,9 @@
</div> </div>
{% endif %} {% endif %}
<div class="cell-buttons"> <div class="cell-buttons">
{% if user.is_staff %}
<a class="edit" href="{% url "admin:inventory_item_change" object_id=item.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a> <a class="edit" href="{% url "admin:inventory_item_change" object_id=item.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
{% endif %}
<a class="details" href="{% url "item-detail" pk=item.pk %}"><img class="icon" src="{% static "inventory/img/detail.svg" %}"></a> <a class="details" href="{% url "item-detail" pk=item.pk %}"><img class="icon" src="{% static "inventory/img/detail.svg" %}"></a>
</div> </div>
@ -28,7 +30,9 @@
{% endif %} {% endif %}
{% else %} {% else %}
<div class="cell-buttons"> <div class="cell-buttons">
{% if user.is_staff %}
<a class="title missing" href="{% url "admin:inventory_item_add" %}?index={{ item.index }}&container={{ item.container_id }}"><br><img class="icon" src="{% static "inventory/img/add.svg" %}"></a> <a class="title missing" href="{% url "admin:inventory_item_add" %}?index={{ item.index }}&container={{ item.container_id }}"><br><img class="icon" src="{% static "inventory/img/add.svg" %}"></a>
{% endif %}
</div> </div>
{% endif %} {% endif %}
</div> </div>

View file

@ -12,14 +12,18 @@
<li> <li>
<a href="{% url 'area-detail' area.id %}" title="{{ area.description }}">{{ area.name }}</a> <a href="{% url 'area-detail' area.id %}" title="{{ area.description }}">{{ area.name }}</a>
({{ area.description }}) ({{ area.description }})
{% if user.is_staff %}
<a class="edit" href="{% url "admin:inventory_area_change" object_id=area.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a> <a class="edit" href="{% url "admin:inventory_area_change" object_id=area.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
{% endif %}
</li> </li>
{% empty %} {% empty %}
<li>No areas defined</li> <li>No areas defined</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% if user.is_staff %}
<p><a href="{% url "admin:inventory_area_add" %}?container={{ workshop.id }}&index=0">Create new area...</a></p> <p><a href="{% url "admin:inventory_area_add" %}?container={{ workshop.id }}&index=0">Create new area...</a></p>
{% endif %}
<h3>Boxes</h3> <h3>Boxes</h3>
<ul> <ul>
@ -27,13 +31,16 @@
<li> <li>
<a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }} ({{ box.layout.name }})</a> <a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }} ({{ box.layout.name }})</a>
({{ box.description }}) ({{ box.description }})
{% if user.is_staff %}
<a class="edit" href="{% url "admin:inventory_box_change" object_id=box.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a> <a class="edit" href="{% url "admin:inventory_box_change" object_id=box.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
{% endif %}
</li> </li>
{% empty %} {% empty %}
<li>No boxes defined</li> <li>No boxes defined</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% if user.is_staff %}
<p><a href="{% url "admin:inventory_box_add" %}?container={{ workshop.id }}&index=0">Create new box...</a></p> <p><a href="{% url "admin:inventory_box_add" %}?container={{ workshop.id }}&index=0">Create new box...</a></p>
{% endif %}
{% endblock %} {% endblock %}

View file

@ -9,11 +9,15 @@
{% for workshop in object_list %} {% for workshop in object_list %}
<li> <li>
<a href="{% url 'workshop-detail' workshop.id %}" title="{{ workshop.description }}">{{ workshop.name }}</a> <a href="{% url 'workshop-detail' workshop.id %}" title="{{ workshop.description }}">{{ workshop.name }}</a>
{% if user.is_staff %}
<a class="edit" href="{% url "admin:inventory_workshop_change" object_id=workshop.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a> <a class="edit" href="{% url "admin:inventory_workshop_change" object_id=workshop.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
{% endif %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
<p><a href="{% url "admin:inventory_workshop_add" %}?layout=1">Create new workshop</a></p> {% if user.is_staff %}
<p><a href="{% url "admin:inventory_workshop_add" %}?layout=1">Create new workshop...</a></p>
{% endif %}
{% endblock %} {% endblock %}