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