From 6e8c2de3df354a80fc56c2630f186b47928eeb39 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Thu, 17 Mar 2022 10:42:20 +0100 Subject: [PATCH] Refactored container types list views to new style. --- .../container/container_type_list.html | 70 ++++++++++++++++--- container/urls.py | 5 +- container/views.py | 17 +++++ 3 files changed, 83 insertions(+), 9 deletions(-) diff --git a/container/templates/container/container_type_list.html b/container/templates/container/container_type_list.html index acfde6d..fcc7d87 100644 --- a/container/templates/container/container_type_list.html +++ b/container/templates/container/container_type_list.html @@ -1,21 +1,75 @@ {% extends "base.html" %} {% load static %} -{% block title %}Container: {{ container.named_id }}{% endblock %} +{% block title %}Container Type List{% endblock %} {% block content %}
{% if container_type_list %} -
New Container Types:
- -
+ + + + + + + + + + + + + + + {% for ctype in container_type_list %} + + + + + + + + + + + {% endfor %} + +
Container TypeDescriptionSize (mm)Inner Size (mm)Coverholds ContainerChangedAction
{{ ctype.named_id }}
{{ ctype.description }}
{% if ctype.width %}{{ ctype.width }}x{{ ctype.length }}x{{ ctype.height }}{% endif %}
{% if ctype.inner_width %}{{ ctype.inner_width }}x{{ ctype.inner_length }}x{{ ctype.inner_height }}{% endif %}
{% if ctype.has_cover %}yes{%else %}--{% endif %}
{% if ctype.contains_container %}yes{%else %}--{% endif %}
{{ ctype.changed_ts | date:'H:i:s d.m.Y' }}
Delete
+ {% else %}

No container types are available.

{% endif %} + +
+ +
+ + + +
+ + {% endblock content %} diff --git a/container/urls.py b/container/urls.py index 7e84868..ef56232 100644 --- a/container/urls.py +++ b/container/urls.py @@ -1,7 +1,8 @@ from django.urls import path from container.views import ContainerListView, ContainerUpdateView, ContainerCreateView, ContainerDetailView, ContainerDeleteView -from container.views import ContainerTypeListView, ContainerTypeDetailView, ContainerTypeCreateView +from container.views import ContainerTypeListView, ContainerTypeDetailView, ContainerTypeCreateView, ContainerTypeUpdateView, ContainerTypeDeleteView + app_name = 'container' urlpatterns = [ path('', ContainerListView.as_view(), name='list'), @@ -11,5 +12,7 @@ urlpatterns = [ path('type/', ContainerTypeListView.as_view(), name='container_type_list'), path('type//', ContainerTypeDetailView.as_view(), name='container_type_detail'), path('type/add/', ContainerTypeCreateView.as_view(), name='container_type_add'), + path('type/edit//', ContainerTypeUpdateView.as_view(), name='container_type_update'), + path('type/delete//', ContainerTypeDeleteView.as_view(), name='container_type_delete'), ] diff --git a/container/views.py b/container/views.py index 0913786..747b49c 100644 --- a/container/views.py +++ b/container/views.py @@ -73,3 +73,20 @@ class ContainerTypeCreateView(generic.CreateView): form.instance.changed_by = self.request.user form.instance.created_by = self.request.user return super().form_valid(form) + + +class ContainerTypeUpdateView(generic.UpdateView): + model = ContainerType + # template_name = 'container/detail.html' + fields = ['named_id', 'description', 'width', 'length', 'height', 'inner_width', 'inner_length', 'inner_height', + 'has_cover', 'contains_container'] + + def form_valid(self, form): + form.instance.changed_by = self.request.user + return super().form_valid(form) + + +class ContainerTypeDeleteView(generic.DetailView): + model = ContainerType + +