add trade instead of deliverynote in lots view

This commit is contained in:
Cayo Puigdefabregas 2021-06-02 10:10:36 +02:00
parent 6c689878a4
commit 57c9269907
1 changed files with 5 additions and 6 deletions

View File

@ -12,9 +12,8 @@ from teal.resource import View
from ereuse_devicehub.db import db from ereuse_devicehub.db import db
from ereuse_devicehub.query import things_response from ereuse_devicehub.query import things_response
from ereuse_devicehub.resources.deliverynote.models import Deliverynote
from ereuse_devicehub.resources.device.models import Device, Computer from ereuse_devicehub.resources.device.models import Device, Computer
from ereuse_devicehub.resources.action.models import Confirm, Revoke from ereuse_devicehub.resources.action.models import Trade, Confirm, Revoke
from ereuse_devicehub.resources.lot.models import Lot, Path from ereuse_devicehub.resources.lot.models import Lot, Path
@ -99,9 +98,9 @@ class LotView(View):
return jsonify(ret) return jsonify(ret)
def visibility_filter(self, query): def visibility_filter(self, query):
query = query.outerjoin(Deliverynote) \ query = query.outerjoin(Trade) \
.filter(or_(Deliverynote.receiver_address == g.user.email, .filter(or_(Trade.user_from == g.user,
Deliverynote.supplier_email == g.user.email, Trade.user_to == g.user,
Lot.owner_id == g.user.id)) Lot.owner_id == g.user.id))
return query return query
@ -110,7 +109,7 @@ class LotView(View):
return query return query
def delete(self, id): def delete(self, id):
lot = Lot.query.filter_by(id=id).one() lot = Lot.query.filter_by(id=id,).one()
lot.delete() lot.delete()
db.session.commit() db.session.commit()
return Response(status=204) return Response(status=204)