Rename resource_fields to scheduled_operation_model. Reorganize imports.

This commit is contained in:
Alexis Lahouze 2016-01-13 11:55:49 +01:00
parent 22fcfb3e42
commit 880a57de96
1 changed files with 8 additions and 7 deletions

View File

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