Order methods.

This commit is contained in:
Alexis Lahouze 2016-01-12 22:58:19 +01:00
parent 1202c8180e
commit e2c8a41ff6
2 changed files with 42 additions and 42 deletions

View File

@ -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>')

View File

@ -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,