From 0ce12bbfbad6855fb19d7979bb2f2f767d0ae651 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 18 Apr 2023 18:15:44 +0200 Subject: [PATCH] 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')}}