Rename resource_fields to scheduled_operation_model. Reorganize imports.
This commit is contained in:
parent
22fcfb3e42
commit
880a57de96
@ -29,12 +29,13 @@ from ..models.operations import Operation
|
|||||||
|
|
||||||
from .. import api
|
from .. import api
|
||||||
|
|
||||||
from ..fields import Object
|
|
||||||
|
|
||||||
from .users import requires_auth
|
from .users import requires_auth
|
||||||
|
|
||||||
|
from ..fields import Object
|
||||||
|
|
||||||
resource_fields = {
|
|
||||||
|
scheduled_operation_model = {
|
||||||
'id': fields.Integer,
|
'id': fields.Integer,
|
||||||
'start_date': fields.DateTime(dt_format='iso8601'),
|
'start_date': fields.DateTime(dt_format='iso8601'),
|
||||||
'stop_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):
|
class ScheduledOperationListResource(Resource):
|
||||||
@marshal_with_field(fields.List(Object(resource_fields)))
|
|
||||||
@requires_auth
|
@requires_auth
|
||||||
|
@marshal_with_field(fields.List(Object(scheduled_operation_model)))
|
||||||
def get(self):
|
def get(self):
|
||||||
"""
|
"""
|
||||||
Get all scheduled operation for an account.
|
Get all scheduled operation for an account.
|
||||||
@ -75,8 +76,8 @@ class ScheduledOperationListResource(Resource):
|
|||||||
ScheduledOperation.account_id == data.account
|
ScheduledOperation.account_id == data.account
|
||||||
).all(), 200
|
).all(), 200
|
||||||
|
|
||||||
@marshal_with_field(Object(resource_fields))
|
|
||||||
@requires_auth
|
@requires_auth
|
||||||
|
@marshal_with_field(Object(scheduled_operation_model))
|
||||||
def post(self):
|
def post(self):
|
||||||
"""
|
"""
|
||||||
Add a new scheduled operation.
|
Add a new scheduled operation.
|
||||||
@ -95,8 +96,8 @@ class ScheduledOperationListResource(Resource):
|
|||||||
|
|
||||||
|
|
||||||
class ScheduledOperationResource(Resource):
|
class ScheduledOperationResource(Resource):
|
||||||
@marshal_with_field(Object(resource_fields))
|
|
||||||
@requires_auth
|
@requires_auth
|
||||||
|
@marshal_with_field(Object(scheduled_operation_model))
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
"""
|
"""
|
||||||
Get scheduled operation.
|
Get scheduled operation.
|
||||||
@ -108,8 +109,8 @@ class ScheduledOperationResource(Resource):
|
|||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
return None, 404
|
return None, 404
|
||||||
|
|
||||||
@marshal_with_field(Object(resource_fields))
|
|
||||||
@requires_auth
|
@requires_auth
|
||||||
|
@marshal_with_field(Object(scheduled_operation_model))
|
||||||
def post(self, id):
|
def post(self, id):
|
||||||
"""
|
"""
|
||||||
Update a scheduled operation.
|
Update a scheduled operation.
|
||||||
@ -138,8 +139,8 @@ class ScheduledOperationResource(Resource):
|
|||||||
|
|
||||||
return scheduled_operation, 200
|
return scheduled_operation, 200
|
||||||
|
|
||||||
@marshal_with_field(Object(resource_fields))
|
|
||||||
@requires_auth
|
@requires_auth
|
||||||
|
@marshal_with_field(Object(scheduled_operation_model))
|
||||||
def delete(self, id):
|
def delete(self, id):
|
||||||
"""
|
"""
|
||||||
Delete a scheduled operation.
|
Delete a scheduled operation.
|
||||||
|
Loading…
Reference in New Issue
Block a user