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_detail.html b/ereuse_devicehub/templates/inventory/device_detail.html index c5e65e37..6b55a799 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,16 @@ {% endif %} - {{ doc.created.strftime('%Y-%m-%d %H:%M')}} + {{ doc.type }} + + + {% if doc.description %} + {{ doc.description|truncate(30, True) }} + {% endif %} + + {{ doc.created.strftime('%Y-%m-%d %H:%M') }} + 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')}}