Make navigation and creation of objects somewhat consistent

This commit is contained in:
Johannes Schriewer 2020-12-22 03:18:32 +01:00
parent 679fd6778c
commit f911a40c50
4 changed files with 144 additions and 46 deletions

View file

@ -1,25 +1,37 @@
{% extends "base.html" %}
{% load static %}
{% block title %}{{ area.container.display_name }} - {{ area.name }}{% endblock %}
{% block content %}
<h2>{{ area.container.display_name }} - {{ area.name }}</h2>
{% if area.area_related.exists %}
<h2><a href="{{ area.container_url }}"><img class="icon" src="{% static "inventory/img/back.svg" %}"></a>{{ area.container.display_name }} - {{ area.name }} <span class="small">{{ area.description}}</span></h2>
<h3>Areas</h3>
<ul>
{% for a in area.area_related.all %}
<li><a href="{% url 'area-detail' a.id %}" title="{{ a.description }}">{{ a.name }}</a></li>
<li>
<a href="{% url 'area-detail' a.id %}" title="{{ a.description }}">{{ a.name }}</a>
<a class="edit" href="{% url "admin:inventory_area_change" object_id=area.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
</li>
{% empty %}
<li>No areas defined</li>
{% endfor %}
</ul>
{% endif %}
{% if area.box_related.exists %}
<p><a href="{% url "admin:inventory_area_add" %}?container={{ area.id }}&index=0">Create new area...</a></p>
<h3>Boxes</h3>
<ul>
{% for box in area.box_related.all %}
<li><a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }} ({{ box.layout.name }})</a></li>
<li>
<a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }} ({{ box.layout.name }})</a>
<a class="edit" href="{% url "admin:inventory_box_change" object_id=box.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
</li>
{% empty %}
<li>No boxes defined</li>
{% endfor %}
</ul>
{% endif %}
<p><a href="{% url "admin:inventory_box_add" %}?container={{ area.id }}&index=0">Create new container...</a></p>
{% endblock %}

View file

@ -1,38 +1,103 @@
{% extends "base.html" %}
{% load static %}
{% load formatstring %}
{% block title %}{{ item.name }}{% endblock %}
{% block content %}
<h2>{{ item.name }}</h2>
<p>{{ item.description }}</p>
<h2><a href="{{ item.container_url }}"><img class="icon" src="{% static "inventory/img/back.svg" %}"></a>{{ item.name }}</h2>
<table class="attribute-list">
<tbody>
<tr>
<th>Description</th>
<td>{{ item.description }}</td>
</tr>
<ul>
{% if item.manufacturer %}
<li>Manufacturer: <a href="{% url 'manufacturer-detail' item.manufacturer.id %}">{% if item.manufacturer.icon %}<img src="{{ item.manufacturer.icon.url }}" class="icon">{% endif %}{{ item.manufacturer.name }}</a></li>
<tr>
<th>Manufacturer</th>
<td>
<a href="{% url 'manufacturer-detail' item.manufacturer.id %}">
{% if item.manufacturer.icon %}<img src="{{ item.manufacturer.icon.url }}" class="icon">{% endif %}
{{ item.manufacturer.name }}
</a>
</td>
</tr>
{% endif %}
{% if item.distributor %}
<li>Distributor: <a href="{% url 'distributor-detail' item.distributor.id %}">{% if item.distributor.icon %}<img src="{{ item.distributor.icon.url }}" class="icon">{% endif %}{{ item.distributor.name }}</a></li>
{% endif %}
{% if item.price %}
<li>Price: {{ item.price }} Euro</li>
{% endif %}
{% if item.last_ordered_on %}
<li>Last ordered: {{ item.last_ordered_on }}</li>
{% endif %}
{% if item.distributor_item_no %}
<li>Link: <a href="{% formatstring item.distributor.search_link item.distributor_item_no %}">{% formatstring item.distributor.search_link item.distributor_item_no %}</a></li>
{% endif %}
<li>Created at: {{ item.created_at }}</li>
<li>Last change: {{ item.changed_at }}</li>
</ul>
{% if item.documentation.exists %}
<h3>Datasheets</h3>
<ul>
{% for doc in item.documentation.all %}
<li><a href="{{ doc.file.url }}">{{ doc.file.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% if item.distributor %}
<tr>
<th>Distributor</th>
<td>
<a href="{% url 'distributor-detail' item.distributor.id %}">
{% if item.distributor.icon %}<img src="{{ item.distributor.icon.url }}" class="icon">{% endif %}
{{ item.distributor.name }}
</a>
</td>
</tr>
{% endif %}
{% if item.form_factor %}
<tr>
<th>Form factor</th>
<td>
{% if item.form_factor.datasheet %}
<a href="{% url 'distributor-detail' item.distributor.id %}">
{% if item.form_factor.icon %}<img src="{{ item.form_factor.icon.url }}" class="icon">{% endif %}
{{ item.form_factor.name }}
</a>
{% else %}
{% if item.form_factor.icon %}<img src="{{ item.form_factor.icon.url }}" class="icon">{% endif %}
{{ item.form_factor.name }}
{% endif %}
({{ item.form_factor.description }})
</td>
</tr>
{% endif %}
{% if item.price %}
<tr>
<th>Price</th>
<td>{{ item.price }} Euro</td>
</tr>
{% endif %}
{% if item.last_ordered_on %}
<tr>
<th>Last ordered</th>
<td>{{ item.last_ordered_on }}</td>
</tr>
{% endif %}
{% if item.distributor_item_no %}
<tr>
<th>Link</th>
<td>
<a href="{% formatstring item.distributor.search_link item.distributor_item_no %}">{% formatstring item.distributor.search_link item.distributor_item_no %}</a>
</td>
</tr>
{% endif %}
<tr><th>Created at</th><td>{{ item.created_at }}</td></tr>
{% if item.created_at != item.changed_at %}
<tr><th>Last change</th><td>{{ item.changed_at }}</td></tr>
{% endif %}
{% if item.documentation.exists %}
<tr>
<th>Datasheets</th>
<td>
<ul>
{% for doc in item.documentation.all %}
<li><a href="{{ doc.file.url }}">{{ doc.file.name }}</a></li>
{% endfor %}
</ul>
</td>
</tr>
{% endif %}
</tbody>
</table>
{% endblock %}

View file

@ -1,25 +1,39 @@
{% extends "base.html" %}
{% load static %}
{% block title %}Workshop {{ workshop.name }}{% endblock %}
{% block content %}
<h2>{{ workshop.name }}</h2>
{% if workshop.area_related.exists %}
<h2><a href="{% url "workshop-list" %}"><img class="icon" src="{% static "inventory/img/back.svg" %}"></a>{{ workshop.name }} <span class="small">{{ workshop.description}}</span></h2>
<h3>Areas</h3>
<ul>
{% for area in workshop.area_related.all %}
<li><a href="{% url 'area-detail' area.id %}" title="{{ area.description }}">{{ area.name }}</a></li>
<li>
<a href="{% url 'area-detail' area.id %}" title="{{ area.description }}">{{ area.name }}</a>
({{ area.description }})
<a class="edit" href="{% url "admin:inventory_area_change" object_id=area.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
</li>
{% empty %}
<li>No areas defined</li>
{% endfor %}
</ul>
{% endif %}
{% if workshop.box_related.exists %}
<p><a href="{% url "admin:inventory_area_add" %}?container={{ workshop.id }}&index=0">Create new area...</a></p>
<h3>Boxes</h3>
<ul>
{% for box in workshop.box_related.all %}
<li><a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }} ({{ box.layout.name }})</a></li>
<li>
<a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }} ({{ box.layout.name }})</a>
({{ box.description }})
<a class="edit" href="{% url "admin:inventory_box_change" object_id=box.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
</li>
{% empty %}
<li>No boxes defined</li>
{% endfor %}
</ul>
{% endif %}
<p><a href="{% url "admin:inventory_box_add" %}?container={{ workshop.id }}&index=0">Create new box...</a></p>
{% endblock %}

View file

@ -1,4 +1,5 @@
{% extends "base.html" %}
{% load static %}
{% block title %}Workshops{% endblock %}
@ -6,7 +7,13 @@
<h2>Workshops</h2>
<ul>
{% for workshop in object_list %}
<li><a href="{% url 'workshop-detail' workshop.id %}" title="{{ workshop.description }}">{{ workshop.name }}</a></li>
<li>
<a href="{% url 'workshop-detail' workshop.id %}" title="{{ workshop.description }}">{{ workshop.name }}</a>
<a class="edit" href="{% url "admin:inventory_workshop_change" object_id=workshop.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
</li>
{% endfor %}
</ul>
<p><a href="{% url "admin:inventory_workshop_add" %}?layout=1">Create new workshop</a></p>
{% endblock %}