diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6b36a2..89548604 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ ml). ## testing +## [2.5.0] - 2022-11-30 +- [added] #407 erasure section with tabs in top. +- [added] #411 add new generic device as Other. +- [changed] #409 add backend pagination instead of javascript. +- [changed] #410 change teh top search for advanced search. +- [fixed] #412 show in snapshots log, type upload correctly. +- [fixed] #413 put order in documents. +- [fixed] #415 put prefix of lot in result of search. + ## [2.4.3] - 2022-11-18 - [added] #386 add registration module. - [added] #387 add template settings for Secure Erasure. diff --git a/ereuse_devicehub/__init__.py b/ereuse_devicehub/__init__.py index 5a8e0983..50062f87 100644 --- a/ereuse_devicehub/__init__.py +++ b/ereuse_devicehub/__init__.py @@ -1 +1 @@ -__version__ = "2.4.3" +__version__ = "2.5.0" diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index fe1c37e7..b9c3a659 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -141,6 +141,7 @@ class ErasureListView(DeviceListMixin): ) if orphans: schema = app.config.get('SCHEMA') + _user = g.user.id sql = f""" select action.id from {schema}.action as action inner join {schema}.erase_basic as erase @@ -149,11 +150,14 @@ class ErasureListView(DeviceListMixin): on device.id=action.parent_id inner join {schema}.placeholder as placeholder on placeholder.binding_id=device.id - where action.parent_id is null or placeholder.kangaroo=true + where (action.parent_id is null or placeholder.kangaroo=true) + and action.author_id='{_user}' """ ids = (e[0] for e in db.session.execute(sql)) - erasure = EraseBasic.query.filter(EraseBasic.id.in_(ids)).order_by( - EraseBasic.created.desc() + erasure = ( + EraseBasic.query.filter(EraseBasic.id.in_(ids)) + .filter_by(author=g.user) + .order_by(EraseBasic.created.desc()) ) self.context['orphans'] = True diff --git a/ereuse_devicehub/parser/models.py b/ereuse_devicehub/parser/models.py index bdd13f73..6d8cdb4e 100644 --- a/ereuse_devicehub/parser/models.py +++ b/ereuse_devicehub/parser/models.py @@ -73,7 +73,7 @@ class SnapshotsLog(Thing): snapshots = [] for s in self.snapshot.device.actions: if s == self.snapshot: - continue + break if s.type == self.snapshot.type: snapshots.append(s) return snapshots and 'Update' or 'New Device' diff --git a/ereuse_devicehub/resources/tradedocument/models.py b/ereuse_devicehub/resources/tradedocument/models.py index 7f211637..07af62d1 100644 --- a/ereuse_devicehub/resources/tradedocument/models.py +++ b/ereuse_devicehub/resources/tradedocument/models.py @@ -172,7 +172,9 @@ class TradeDocument(Thing): return sorted(ev for ev in actions if ev.severity >= Severity.Warning) def __lt__(self, other): - return self.id < other.id + if self.id and other.id: + return self.id < other.id + return False def __str__(self) -> str: return '{0.file_name}'.format(self) diff --git a/ereuse_devicehub/templates/inventory/search.html b/ereuse_devicehub/templates/inventory/search.html index 9f724586..57f62975 100644 --- a/ereuse_devicehub/templates/inventory/search.html +++ b/ereuse_devicehub/templates/inventory/search.html @@ -16,7 +16,7 @@
-
+
@@ -307,8 +307,8 @@ {% if dev.lots | length > 0 %}
- {% for lot in dev.lots %} - {{ lot.name }} + {% for lot in dev.get_lots_for_template() %} + {{ lot }} {% endfor %}
{% endif %} diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index fbd437d9..f9f2299e 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -2470,6 +2470,7 @@ def test_bug_3831_documents(user3: UserClientFlask): assert 'Delete Lot' in body assert 'Incoming Lot' in body + lot_id = Lot.query.all()[1].id uri = f'/inventory/lot/{lot_id}/trade-document/add/' body, status = user3.get(uri) @@ -2487,8 +2488,16 @@ def test_bug_3831_documents(user3: UserClientFlask): } uri = f'/inventory/lot/{lot_id}/trade-document/add/' - # body, status = user3.post(uri, data=data, content_type="multipart/form-data") - # assert status == '200 OK' + body, status = user3.post(uri, data=data, content_type="multipart/form-data") + assert status == '200 OK' + + # Second document + uri = f'/inventory/lot/{lot_id}/trade-document/add/' + file_upload = (BytesIO(b_file), file_name) + data['file'] = file_upload + data['csrf_token'] = generate_csrf() + body, status = user3.post(uri, data=data, content_type="multipart/form-data") + assert status == '200 OK' @pytest.mark.mvp