User __dict__.get to avoid long lines.
This commit is contained in:
parent
a8672a8656
commit
6c3f73cd75
@ -148,7 +148,7 @@ class AccountListResource(Resource):
|
||||
data = self.api.payload
|
||||
|
||||
# A new account MUST NOT have an id;
|
||||
if 'id' in data and data['id']:
|
||||
if data.get('id') is not None:
|
||||
ns.abort(406, 'Id must not be provided on creation.')
|
||||
|
||||
# Instantiate account with data.
|
||||
@ -203,7 +203,7 @@ class AccountResource(Resource):
|
||||
data = self.api.payload
|
||||
|
||||
# Check ID consistency.
|
||||
if 'id' in data and data['id'] and data['id'] != account_id:
|
||||
if data.get('id', default=account_id) != account_id:
|
||||
ns.abort(406, 'Id must not be provided or changed on update.')
|
||||
|
||||
# Need to get the object to update it.
|
||||
|
@ -132,7 +132,7 @@ class OperationListResource(Resource):
|
||||
ns.abort(404, 'Account with id %d not found.' % account_id)
|
||||
|
||||
# A new operation MUST NOT have an id;
|
||||
if 'id' in data and data['id']:
|
||||
if data.get('id') is not None:
|
||||
ns.abort(406, 'Id must not be provided on creation.')
|
||||
|
||||
operation = Operation(**data)
|
||||
@ -181,7 +181,7 @@ class OperationResource(Resource):
|
||||
data = self.api.payload
|
||||
|
||||
# Check ID consistency.
|
||||
if 'id' in data and data['id'] and data['id'] != operation_id:
|
||||
if data.get('id', default=operation_id) != operation_id:
|
||||
ns.abort(406, 'Id must not be provided or changed on update.')
|
||||
|
||||
# pylint: disable=no-member
|
||||
|
@ -106,7 +106,7 @@ class ScheduledOperationListResource(Resource):
|
||||
ns.abort(404, 'Account with id %d not found.' % account_id)
|
||||
|
||||
# A new scheduled operation MUST NOT have an id;
|
||||
if 'id' in data and data['id']:
|
||||
if data.get('id') is not None:
|
||||
ns.abort(406, 'Id must not be provided on creation.')
|
||||
|
||||
scheduled_operation = ScheduledOperation(**data)
|
||||
@ -160,7 +160,7 @@ class ScheduledOperationResource(Resource):
|
||||
so_id = scheduled_operation_id
|
||||
|
||||
# Check ID consistency.
|
||||
if 'id' in data and data['id'] and data['id'] != so_id:
|
||||
if data.get('id', default=so_id) != so_id:
|
||||
ns.abort(406, 'Id must not be provided or changed on update.')
|
||||
|
||||
scheduled_operation = ScheduledOperation.query().get(so_id)
|
||||
|
Loading…
Reference in New Issue
Block a user