Order methods.
This commit is contained in:
parent
1202c8180e
commit
e2c8a41ff6
@ -110,19 +110,6 @@ class AccountResource(Resource):
|
||||
except NoResultFound:
|
||||
return None, 404
|
||||
|
||||
@requires_auth
|
||||
@marshal_with_field(Object(resource_fields))
|
||||
def delete(self, id):
|
||||
# Need to get the object to update it.
|
||||
account = db.session.query(Account).get(id)
|
||||
|
||||
if not account:
|
||||
return None, 404
|
||||
|
||||
db.session.delete(account)
|
||||
|
||||
return None, 204
|
||||
|
||||
@requires_auth
|
||||
@marshal_with_field(Object(resource_fields))
|
||||
def post(self, id):
|
||||
@ -148,6 +135,19 @@ class AccountResource(Resource):
|
||||
Account.id == id
|
||||
).one()
|
||||
|
||||
@requires_auth
|
||||
@marshal_with_field(Object(resource_fields))
|
||||
def delete(self, id):
|
||||
# Need to get the object to update it.
|
||||
account = db.session.query(Account).get(id)
|
||||
|
||||
if not account:
|
||||
return None, 404
|
||||
|
||||
db.session.delete(account)
|
||||
|
||||
return None, 204
|
||||
|
||||
|
||||
api_api.add_resource(AccountListResource, '/accounts')
|
||||
api_api.add_resource(AccountResource, '/accounts/<int:id>')
|
||||
|
@ -102,35 +102,6 @@ class ScheduledOperationResource(Resource):
|
||||
except NoResultFound:
|
||||
return None, 404
|
||||
|
||||
@marshal_with_field(Object(resource_fields))
|
||||
def delete(self, id):
|
||||
"""
|
||||
Delete a scheduled operation.
|
||||
"""
|
||||
try:
|
||||
scheduled_operation = ScheduledOperation.query().filter(
|
||||
ScheduledOperation.id == id
|
||||
).one()
|
||||
except NoResultFound:
|
||||
return None, 404
|
||||
|
||||
operations = scheduled_operation.operations.filter(
|
||||
Operation.confirmed == true()
|
||||
).count()
|
||||
|
||||
import ipdb; ipdb.set_trace()
|
||||
|
||||
if operations:
|
||||
return "There are still confirmed operations associated to this \
|
||||
scheduled operation.", 409
|
||||
|
||||
# Delete unconfirmed operations
|
||||
operations = scheduled_operation.operations.delete()
|
||||
|
||||
db.session.delete(scheduled_operation)
|
||||
|
||||
return None, 204
|
||||
|
||||
@marshal_with_field(Object(resource_fields))
|
||||
def post(self, id):
|
||||
"""
|
||||
@ -160,6 +131,35 @@ class ScheduledOperationResource(Resource):
|
||||
|
||||
return scheduled_operation
|
||||
|
||||
@marshal_with_field(Object(resource_fields))
|
||||
def delete(self, id):
|
||||
"""
|
||||
Delete a scheduled operation.
|
||||
"""
|
||||
try:
|
||||
scheduled_operation = ScheduledOperation.query().filter(
|
||||
ScheduledOperation.id == id
|
||||
).one()
|
||||
except NoResultFound:
|
||||
return None, 404
|
||||
|
||||
operations = scheduled_operation.operations.filter(
|
||||
Operation.confirmed == true()
|
||||
).count()
|
||||
|
||||
import ipdb; ipdb.set_trace()
|
||||
|
||||
if operations:
|
||||
return "There are still confirmed operations associated to this \
|
||||
scheduled operation.", 409
|
||||
|
||||
# Delete unconfirmed operations
|
||||
operations = scheduled_operation.operations.delete()
|
||||
|
||||
db.session.delete(scheduled_operation)
|
||||
|
||||
return None, 204
|
||||
|
||||
|
||||
api_api.add_resource(ScheduledOperationListResource, "/scheduled_operations")
|
||||
api_api.add_resource(ScheduledOperationResource,
|
||||
|
Loading…
Reference in New Issue
Block a user