Change get query for scheduled operation.

Alexis Lahouze
2016-01-13 18:36:22 +01:00
parent f961eba9bf
commit 92d3cc1c7d

@@ -19,7 +19,6 @@ import dateutil.parser
from flask.ext.restful import Resource, fields, reqparse, marshal_with_field
from sqlalchemy import true
from sqlalchemy.orm.exc import NoResultFound
from accountant import db
@@ -99,13 +98,13 @@ class ScheduledOperationResource(Resource):
"""
Get scheduled operation.
"""
try:
return ScheduledOperation.query().filter(
ScheduledOperation.id == id
).one(), 200
except NoResultFound:
scheduled_operation = ScheduledOperation.query().get(id)
if not scheduled_operation:
return None, 404
return scheduled_operation, 200
@requires_auth
@marshal_with_field(Object(scheduled_operation_model))
def post(self, id):
@@ -117,11 +116,9 @@ class ScheduledOperationResource(Resource):
assert (id not in data or data.id is None
or data.id == id)
try:
scheduled_operation = ScheduledOperation.query().filter(
ScheduledOperation.id == id
).one()
except NoResultFound:
scheduled_operation = ScheduledOperation.query().get(id)
if not scheduled_operation:
return None, 404
# SQLAlchemy objects ignore __dict__.update() with merge.
@@ -142,11 +139,9 @@ class ScheduledOperationResource(Resource):
"""
Delete a scheduled operation.
"""
try:
scheduled_operation = ScheduledOperation.query().filter(
ScheduledOperation.id == id
).one()
except NoResultFound:
scheduled_operation = ScheduledOperation.query().get(id)
if not scheduled_operation:
return None, 404
operations = scheduled_operation.operations.filter(