Revert "Changing devices transfer_states on delivery note PATCH"

This reverts commit 5c562752
This commit is contained in:
nad 2020-08-25 15:57:17 +02:00
parent 5c56275228
commit 9fa96c3d3b
1 changed files with 8 additions and 9 deletions

View File

@ -6,7 +6,6 @@ from teal.resource import View
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.deliverynote.models import Deliverynote
from ereuse_devicehub.resources.device.models import Computer
from ereuse_devicehub.resources.lot.models import Lot
@ -33,17 +32,17 @@ class DeliverynoteView(View):
'ethereum_address'), partial=True)
d = request.get_json(schema=patch_schema)
dlvnote = Deliverynote.query.filter_by(id=id).one()
device_fields = ['transfer_state', 'deliverynote_address']
computers = [x for x in dlvnote.transferred_devices if isinstance(x, Computer)]
# device_fields = ['transfer_state', 'deliverynote_address']
# computers = [x for x in dlvnote.transferred_devices if isinstance(x, Computer)]
for key, value in d.items():
setattr(dlvnote, key, value)
# Transalate ethereum_address attribute
devKey = key
if key == 'ethereum_address':
devKey = 'deliverynote_address'
if devKey in device_fields:
for dev in computers:
setattr(dev, devKey, value)
# devKey = key
# if key == 'ethereum_address':
# devKey = 'deliverynote_address'
# if devKey in device_fields:
# for dev in computers:
# setattr(dev, devKey, value)
db.session.commit()
return Response(status=204)