Add template and static files for SMD-Boxall
This commit is contained in:
parent
13fb8f7f3e
commit
ffb8c1cef4
8 changed files with 218 additions and 4 deletions
43
inventory/static/inventory/css/box-all.css
Normal file
43
inventory/static/inventory/css/box-all.css
Normal file
|
@ -0,0 +1,43 @@
|
|||
tr {
|
||||
height: 75px;
|
||||
}
|
||||
|
||||
.cell .title {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.cell .package {
|
||||
position: absolute;
|
||||
display: inline;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
font-size: xx-small;
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.cell .price {
|
||||
position: absolute;
|
||||
display: inline;
|
||||
bottom: 5px;
|
||||
left: 5px;
|
||||
font-size: xx-small;
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.cell .shop {
|
||||
position: absolute;
|
||||
bottom: 5px;
|
||||
right: 5px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.cell a {
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.missing-link {
|
||||
color: #c00000;
|
||||
}
|
78
inventory/static/inventory/css/main.css
Normal file
78
inventory/static/inventory/css/main.css
Normal file
|
@ -0,0 +1,78 @@
|
|||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
|
||||
td {
|
||||
text-align: center;
|
||||
|
||||
border-color: #d0d0d0;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: center;
|
||||
font-weight: 800;
|
||||
padding: 20px;
|
||||
|
||||
border-color: #808080;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
main {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
@media (min-width: 1025px) {
|
||||
h1 {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
main {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
h1 {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
main {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.missing {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
td:hover .missing {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.edit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
td:hover .edit {
|
||||
display: inline;
|
||||
}
|
BIN
inventory/static/inventory/img/add.png
Normal file
BIN
inventory/static/inventory/img/add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 258 B |
BIN
inventory/static/inventory/img/edit.png
Normal file
BIN
inventory/static/inventory/img/edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 310 B |
|
@ -4,8 +4,8 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
<link rel="stylesheet" content="text/css" href="{% static 'main.css' %}">
|
||||
{% block header %}{% endblock %}
|
||||
<link rel="stylesheet" content="text/css" href="{% static 'inventory/css/main.css' %}">
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
|
|
65
inventory/templates/inventory/box-smd-boxall.html
Normal file
65
inventory/templates/inventory/box-smd-boxall.html
Normal file
|
@ -0,0 +1,65 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load admin_urls %}
|
||||
|
||||
{% block head %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static "inventory/css/box-all.css" %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{{ context.title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ object.name }}</h1>
|
||||
|
||||
{% for part in layouted %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
{% for item in part.0 %}
|
||||
<th>{{ forloop.counter }}</th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for line in part %}
|
||||
<tr>
|
||||
<th>{{ forloop.counter }}</th>
|
||||
{% for column in line %}
|
||||
<td>
|
||||
<div class="cell">
|
||||
{% if column.name %}
|
||||
{% if column.metadata.package %}
|
||||
<div class="package">{{ column.metadata.package }}</div>
|
||||
{% endif %}
|
||||
{% if column.documentation.all %}
|
||||
<a class="title" href="{{ column.documentation.all.0.file.url }}" {% if column.description %}title="{{ column.description }}"{% endif %}>
|
||||
{{ column.name | linebreaksbr }}
|
||||
</a>
|
||||
{% else %}
|
||||
<div class="title missing-link" title="{{ column.description }}">
|
||||
{{ column.name | linebreaksbr }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<a class="edit" href="{% url "admin:inventory_item_change" object_id=column.pk %}"><img src="{% static "inventory/img/edit.png" %}"></a>
|
||||
|
||||
{% if column.price %}
|
||||
<div class="price">{{ column.price | floatformat:2 }} €</div>
|
||||
{% endif %}
|
||||
{% if column.distributor %}
|
||||
<img class="shop" src="{{ column.distributor.icon.url }}" title="{{ column.distributor.name }}">
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a class="title missing" href="{% url "admin:inventory_item_add" %}?index={{ column.index }}&container={{ column.container_id }}"><img src="{% static "inventory/img/add.png" %}"></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<br><br>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
|
@ -8,10 +8,38 @@ from inventory.models import Box
|
|||
@method_decorator(login_required, name='dispatch')
|
||||
class BoxView(DetailView):
|
||||
context_object_name = 'box'
|
||||
queryset = Box.objects.all().select_related('container', 'layout').prefetch_related('box_related')
|
||||
template_name_field = 'template_name'
|
||||
queryset = Box.objects.all().select_related('container', 'layout').prefetch_related('box_related').order_by('index', 'id')
|
||||
|
||||
def layout(self, obj, layout, idx=0):
|
||||
result = []
|
||||
for sublayout in layout:
|
||||
if isinstance(sublayout, list):
|
||||
resulting_sublayout, new_idx = self.layout(obj, sublayout, idx=idx)
|
||||
result.append(resulting_sublayout)
|
||||
idx = new_idx
|
||||
else:
|
||||
instances = obj.filter(index=idx)
|
||||
if instances.count() == 1:
|
||||
result.append(instances.first())
|
||||
elif instances.count() > 1:
|
||||
sub = list(instances)
|
||||
result.append(sub)
|
||||
else:
|
||||
result.append({
|
||||
"index": idx,
|
||||
"container_id": self.object.item_related.first().container_id
|
||||
})
|
||||
idx += 1
|
||||
return result, idx
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
context = self.get_context_data(object=self.object)
|
||||
context['layouted'], _ = self.layout(self.object.item_related.all(), self.object.layout.data)
|
||||
return self.render_to_response(context)
|
||||
|
||||
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
class BoxListView(ListView):
|
||||
model = Box
|
||||
|
||||
|
|
Loading…
Reference in a new issue