From b6b8c6a1f92cf5bec86bda4b76d68f5ead5a806d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 18 Apr 2023 10:10:43 +0200 Subject: [PATCH 1/3] add new columns --- .../templates/inventory/device_detail.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/templates/inventory/device_detail.html b/ereuse_devicehub/templates/inventory/device_detail.html index c5e65e37..5aa45f06 100644 --- a/ereuse_devicehub/templates/inventory/device_detail.html +++ b/ereuse_devicehub/templates/inventory/device_detail.html @@ -214,6 +214,8 @@ File + Type + Description Uploaded on @@ -230,8 +232,14 @@ {% endif %} - {{ doc.created.strftime('%Y-%m-%d %H:%M')}} + {{ doc.type }} + + + {{ doc.description|truncate(30, True) }} + + {{ doc.created.strftime('%Y-%m-%d %H:%M') }} + From 6692233a22ee10d4b774d1b9c1335fa53168a725 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 18 Apr 2023 11:08:43 +0200 Subject: [PATCH 2/3] fix --- ereuse_devicehub/templates/inventory/device_detail.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ereuse_devicehub/templates/inventory/device_detail.html b/ereuse_devicehub/templates/inventory/device_detail.html index 5aa45f06..6b55a799 100644 --- a/ereuse_devicehub/templates/inventory/device_detail.html +++ b/ereuse_devicehub/templates/inventory/device_detail.html @@ -235,7 +235,9 @@ {{ doc.type }} + {% if doc.description %} {{ doc.description|truncate(30, True) }} + {% endif %} {{ doc.created.strftime('%Y-%m-%d %H:%M') }} From 0ce12bbfbad6855fb19d7979bb2f2f767d0ae651 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 18 Apr 2023 18:15:44 +0200 Subject: [PATCH 3/3] fix it --- ereuse_devicehub/inventory/forms.py | 12 ++++++++++++ .../templates/inventory/device_list.html | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index bbc0ea1b..9995ace9 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -1293,6 +1293,8 @@ class TradeDocumentForm(FlaskForm): ).one() kwargs['obj'] = self._obj + if self._obj: + self.file_name.args = () super().__init__(*args, **kwargs) if self._obj: @@ -1313,6 +1315,10 @@ class TradeDocumentForm(FlaskForm): def save(self, commit=True): file_name = '' file_hash = '' + if self._obj: + file_name = self._obj.file_name + file_hash = self._obj.file_hash + if self.file_name.data: file_name = self.file_name.data.filename file_hash = insert_hash(self.file_name.data.read(), commit=False) @@ -1393,6 +1399,8 @@ class DeviceDocumentForm(FlaskForm): ).one() kwargs['obj'] = self._obj + if self._obj: + self.file_name.args = () super().__init__(*args, **kwargs) if self._obj: @@ -1410,6 +1418,10 @@ class DeviceDocumentForm(FlaskForm): def save(self, commit=True): file_name = '' file_hash = '' + if self._obj: + file_name = self._obj.file_name + file_hash = self._obj.file_hash + if self.file_name.data: file_name = self.file_name.data.filename file_hash = insert_hash(self.file_name.data.read(), commit=False) diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index cc304687..c89ff6d5 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -529,6 +529,7 @@ File + Description Uploaded on @@ -543,6 +544,11 @@ {{ doc.file_name}} {% endif %} + + {% if doc.description %} + {{ doc.description|truncate(30, True) }} + {% endif %} + {{ doc.created.strftime('%Y-%m-%d %H:%M')}}