diff --git a/accountant/api/views/scheduled_operations.py b/accountant/api/views/scheduled_operations.py index 2b475fd..21895df 100644 --- a/accountant/api/views/scheduled_operations.py +++ b/accountant/api/views/scheduled_operations.py @@ -29,12 +29,13 @@ from ..models.operations import Operation from .. import api -from ..fields import Object from .users import requires_auth +from ..fields import Object -resource_fields = { + +scheduled_operation_model = { 'id': fields.Integer, 'start_date': fields.DateTime(dt_format='iso8601'), 'stop_date': fields.DateTime(dt_format='iso8601'), @@ -63,8 +64,8 @@ get_parser.add_argument('account', type=int) class ScheduledOperationListResource(Resource): - @marshal_with_field(fields.List(Object(resource_fields))) @requires_auth + @marshal_with_field(fields.List(Object(scheduled_operation_model))) def get(self): """ Get all scheduled operation for an account. @@ -75,8 +76,8 @@ class ScheduledOperationListResource(Resource): ScheduledOperation.account_id == data.account ).all(), 200 - @marshal_with_field(Object(resource_fields)) @requires_auth + @marshal_with_field(Object(scheduled_operation_model)) def post(self): """ Add a new scheduled operation. @@ -95,8 +96,8 @@ class ScheduledOperationListResource(Resource): class ScheduledOperationResource(Resource): - @marshal_with_field(Object(resource_fields)) @requires_auth + @marshal_with_field(Object(scheduled_operation_model)) def get(self, id): """ Get scheduled operation. @@ -108,8 +109,8 @@ class ScheduledOperationResource(Resource): except NoResultFound: return None, 404 - @marshal_with_field(Object(resource_fields)) @requires_auth + @marshal_with_field(Object(scheduled_operation_model)) def post(self, id): """ Update a scheduled operation. @@ -138,8 +139,8 @@ class ScheduledOperationResource(Resource): return scheduled_operation, 200 - @marshal_with_field(Object(resource_fields)) @requires_auth + @marshal_with_field(Object(scheduled_operation_model)) def delete(self, id): """ Delete a scheduled operation.