From 4be07130c2039e692ca495f2a7001c1cefec2464 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 29 Nov 2022 18:09:53 +0100 Subject: [PATCH 1/8] fixed --- ereuse_devicehub/parser/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' From b1ad7b151d763b24c99adafdf09215694b476b9e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 10:23:51 +0100 Subject: [PATCH 2/8] fix orther without id --- ereuse_devicehub/resources/tradedocument/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) From 9fbdaf583444bb8f7120165860edb60535e55efc Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 10:59:56 +0100 Subject: [PATCH 3/8] add test --- tests/test_render_2_0.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index f9f82928..74f57c1f 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -2454,6 +2454,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) @@ -2471,8 +2472,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 From 7be17ead5832b856ba8585b01dda6be18a5b21e1 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 13:10:49 +0100 Subject: [PATCH 4/8] release 2.5.0 --- CHANGELOG.md | 8 ++++++++ ereuse_devicehub/__init__.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6b36a2..9690f6fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ 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. + ## [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" From e36f813d92f0d29333e760eaa2d59338ead99fbf Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 13:28:17 +0100 Subject: [PATCH 5/8] put prefix in lots in result of search --- ereuse_devicehub/templates/inventory/search.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 %} From 7bc4a7d387e593e6728c37223c1dbb15c70b4c67 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 13:31:37 +0100 Subject: [PATCH 6/8] CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9690f6fa..89548604 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ml). - [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. From fe9c2c1c2d985392237c932a815576dd5d0ac6d3 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 15:19:59 +0100 Subject: [PATCH 7/8] fix bug privacity --- ereuse_devicehub/inventory/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index fe1c37e7..a9b44d50 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -152,8 +152,10 @@ class ErasureListView(DeviceListMixin): where action.parent_id is null or placeholder.kangaroo=true """ 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 From 341a7b20345e0b0eb07c0a2f52c8cc03c364607c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 15:26:16 +0100 Subject: [PATCH 8/8] fix bug privacity --- ereuse_devicehub/inventory/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index a9b44d50..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,7 +150,8 @@ 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 = (