From 6017476822c8f08be23fb24763aa48aeacfa4471 Mon Sep 17 00:00:00 2001 From: nad Date: Mon, 3 Aug 2020 18:25:55 +0200 Subject: [PATCH] Adding query to Lot views --- ereuse_devicehub/resources/documents/documents.py | 3 ++- ereuse_devicehub/resources/lot/views.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/resources/documents/documents.py b/ereuse_devicehub/resources/documents/documents.py index 57b8844c..d95e13f9 100644 --- a/ereuse_devicehub/resources/documents/documents.py +++ b/ereuse_devicehub/resources/documents/documents.py @@ -131,7 +131,8 @@ class DevicesDocumentView(DeviceView): class LotsDocumentView(LotView): def find(self, args: dict): - return self.generate_lots_csv(Lot.query) + query = self.query(args) + return self.generate_lots_csv(query) def generate_lots_csv(self, query): """Get lot query and put information in csv format.""" diff --git a/ereuse_devicehub/resources/lot/views.py b/ereuse_devicehub/resources/lot/views.py index 3590ba49..1092e3ea 100644 --- a/ereuse_devicehub/resources/lot/views.py +++ b/ereuse_devicehub/resources/lot/views.py @@ -94,6 +94,10 @@ class LotView(View): ) return jsonify(ret) + def query(self, args): + query = Lot.query.distinct() + return query + def delete(self, id): lot = Lot.query.filter_by(id=id).one() lot.delete()