Revert "Changing devices transfer_states on delivery note PATCH"
This reverts commit 5c562752
This commit is contained in:
parent
5c56275228
commit
9fa96c3d3b
|
@ -6,7 +6,6 @@ from teal.resource import View
|
||||||
|
|
||||||
from ereuse_devicehub.db import db
|
from ereuse_devicehub.db import db
|
||||||
from ereuse_devicehub.resources.deliverynote.models import Deliverynote
|
from ereuse_devicehub.resources.deliverynote.models import Deliverynote
|
||||||
from ereuse_devicehub.resources.device.models import Computer
|
|
||||||
from ereuse_devicehub.resources.lot.models import Lot
|
from ereuse_devicehub.resources.lot.models import Lot
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,17 +32,17 @@ class DeliverynoteView(View):
|
||||||
'ethereum_address'), partial=True)
|
'ethereum_address'), partial=True)
|
||||||
d = request.get_json(schema=patch_schema)
|
d = request.get_json(schema=patch_schema)
|
||||||
dlvnote = Deliverynote.query.filter_by(id=id).one()
|
dlvnote = Deliverynote.query.filter_by(id=id).one()
|
||||||
device_fields = ['transfer_state', 'deliverynote_address']
|
# device_fields = ['transfer_state', 'deliverynote_address']
|
||||||
computers = [x for x in dlvnote.transferred_devices if isinstance(x, Computer)]
|
# computers = [x for x in dlvnote.transferred_devices if isinstance(x, Computer)]
|
||||||
for key, value in d.items():
|
for key, value in d.items():
|
||||||
setattr(dlvnote, key, value)
|
setattr(dlvnote, key, value)
|
||||||
# Transalate ethereum_address attribute
|
# Transalate ethereum_address attribute
|
||||||
devKey = key
|
# devKey = key
|
||||||
if key == 'ethereum_address':
|
# if key == 'ethereum_address':
|
||||||
devKey = 'deliverynote_address'
|
# devKey = 'deliverynote_address'
|
||||||
if devKey in device_fields:
|
# if devKey in device_fields:
|
||||||
for dev in computers:
|
# for dev in computers:
|
||||||
setattr(dev, devKey, value)
|
# setattr(dev, devKey, value)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return Response(status=204)
|
return Response(status=204)
|
||||||
|
|
Reference in New Issue