Adding query to Lot views

This commit is contained in:
nad 2020-08-03 18:25:55 +02:00
parent a2303498cd
commit 6017476822
2 changed files with 6 additions and 1 deletions

View File

@ -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."""

View File

@ -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()