Container type import from excel files

This commit is contained in:
2022-04-01 19:28:10 +02:00
parent 9396cd4903
commit 61edb7e538
7 changed files with 209 additions and 11 deletions

View File

@@ -30,9 +30,6 @@
</div>
</div>
<table>
</table>
<!-- Action buttons -->
<div class="row">

View File

@@ -0,0 +1,18 @@
{% extends "base.html" %}
{% load static %}
{% block title %}Edit Container: {{ container.named_id }}{% endblock %}
{% block content %}
<div class="container">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<div>
<input type="submit" class="btn btn-primary" value="Save">
<a class="btn btn-primary" href="{% url 'container:list' %}">Container List</a>
</div>
</form>
</div>
{% endblock content %}

View File

@@ -0,0 +1,63 @@
{% extends "base.html" %}
{% load static %}
{% block title %}Container Type Import{% endblock %}
{% block content %}
<div class="container">
<div class="row">
<div class="col-sm-12">
<h2>Container Type Import: {{ import_file }}</h2>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{% if not import_file %}
<input type="file" id="import_file" name="import_file" class="form-control">
{% endif %}
{% if import_file %}
<label for="first_data_row">First data row:</label><input type="number" min="1" max="10" size="3" name="first_data_row" id="first_data_row" value="1"><br />
<input type="submit" class="btn btn-primary" value="import" name="import-cmd">
{% else %}
<input type="submit" class="btn btn-primary" value="show" name="show-cmd">
{% endif %}
<div>
{% if import_file %}
File to be imported: {{ import_file }}
{% endif %}
<br>
{% for file in FILES %}
File: {{ file.name }} ({{ file.size }} Bytes)
{% endfor %}
</div>
<div>
<table class="table">
<tr>
<td>Row</td>
<td>ID</td>
<td>Description</td>
<td>Width</td>
<td>Length</td>
<td>Height</td>
<td>Cover</td>
<td>Inner Width</td>
<td>Inner Length</td>
<td>Inner Height</td>
<td>Available</td>
<td>Stores Container</td>
</tr>
{% for row in excel_data %}
<tr>
{% for col in row %}
<td>{{ col }}<input type="hidden" value="{{ col }}" name="data_{{ row.0 }}_{{ forloop.counter }}"></td>
{% endfor %}
</tr>
{% endfor %}
</table>
</div>
</form>
</div>
</div>
</div>
{% endblock content %}

View File

@@ -22,7 +22,7 @@
<tbody>
{% for ctype in container_type_list %}
<tr>
<td><a href="{% url 'container:container_type_detail' ctype.id %}"><div>{{ ctype.named_id }}</div></a></td>
<td><a href="{% url 'container:container_type_update' ctype.id %}"><div>{{ ctype.named_id }}</div></a></td>
<td><div>{{ ctype.description }}</div></td>
<td><div>{% if ctype.width %}{{ ctype.width }}x{{ ctype.length }}x{{ ctype.height }}{% endif %}</div></td>
<td><div>{% if ctype.inner_width %}{{ ctype.inner_width }}x{{ ctype.inner_length }}x{{ ctype.inner_height }}{% endif %}</div></td>
@@ -66,6 +66,9 @@
<a class="btn btn-primary" href="{% url 'container:add' %}" role="button">+ Container</a>
<a class="btn btn-primary" href="{% url 'asset:add' %}" role="button">+ Asset</a>
</div>
<div class="col-sm-12">
<a class="btn btn-primary" href="{% url 'container:container_type_import' %}" role="button">Import Container Types</a>
</div>
</div>
<!-- End Action buttons -->