Merge pull request #445 from eReuse/feature/4319-add-columns-list-documents-device

fix FileField
This commit is contained in:
cayop 2023-04-19 11:19:37 +02:00 committed by GitHub
commit 6dce475256
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -1293,6 +1293,8 @@ class TradeDocumentForm(FlaskForm):
).one() ).one()
kwargs['obj'] = self._obj kwargs['obj'] = self._obj
if self._obj:
self.file_name.args = ()
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
if self._obj: if self._obj:
@ -1313,6 +1315,10 @@ class TradeDocumentForm(FlaskForm):
def save(self, commit=True): def save(self, commit=True):
file_name = '' file_name = ''
file_hash = '' file_hash = ''
if self._obj:
file_name = self._obj.file_name
file_hash = self._obj.file_hash
if self.file_name.data: if self.file_name.data:
file_name = self.file_name.data.filename file_name = self.file_name.data.filename
file_hash = insert_hash(self.file_name.data.read(), commit=False) file_hash = insert_hash(self.file_name.data.read(), commit=False)
@ -1393,6 +1399,8 @@ class DeviceDocumentForm(FlaskForm):
).one() ).one()
kwargs['obj'] = self._obj kwargs['obj'] = self._obj
if self._obj:
self.file_name.args = ()
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
if self._obj: if self._obj:
@ -1410,6 +1418,10 @@ class DeviceDocumentForm(FlaskForm):
def save(self, commit=True): def save(self, commit=True):
file_name = '' file_name = ''
file_hash = '' file_hash = ''
if self._obj:
file_name = self._obj.file_name
file_hash = self._obj.file_hash
if self.file_name.data: if self.file_name.data:
file_name = self.file_name.data.filename file_name = self.file_name.data.filename
file_hash = insert_hash(self.file_name.data.read(), commit=False) file_hash = insert_hash(self.file_name.data.read(), commit=False)

View file

@ -529,6 +529,7 @@
<thead> <thead>
<tr> <tr>
<th scope="col">File</th> <th scope="col">File</th>
<th scope="col">Description</th>
<th scope="col" data-type="date" data-format="YYYY-MM-DD hh:mm">Uploaded on</th> <th scope="col" data-type="date" data-format="YYYY-MM-DD hh:mm">Uploaded on</th>
<th></th> <th></th>
</tr> </tr>
@ -543,6 +544,11 @@
{{ doc.file_name}} {{ doc.file_name}}
{% endif %} {% endif %}
</td> </td>
<td>
{% if doc.description %}
{{ doc.description|truncate(30, True) }}
{% endif %}
</td>
<td> <td>
{{ doc.created.strftime('%Y-%m-%d %H:%M')}} {{ doc.created.strftime('%Y-%m-%d %H:%M')}}
</td> </td>