Rename resource_fields to operation_with_sold_model. Reorganize imports.

This commit is contained in:
Alexis Lahouze 2016-01-13 11:49:10 +01:00
parent cc6f7e2a36
commit 02720a3fb6

View File

@ -24,12 +24,12 @@ from .. import api
from ..models.operations import Operation
from ..fields import Object
from .users import requires_auth
from ..fields import Object
resource_fields = {
operation_with_sold_model = {
'id': fields.Integer(default=None),
'operation_date': fields.DateTime(dt_format='iso8601'),
'label': fields.String,
@ -65,7 +65,7 @@ range_parser.add_argument('end', type=lambda a: dateutil.parser.parse(a))
class OperationListResource(Resource):
@requires_auth
@marshal_with_field(fields.List(Object(resource_fields)))
@marshal_with_field(fields.List(Object(operation_with_sold_model)))
def get(self):
data = range_parser.parse_args()
@ -77,7 +77,7 @@ class OperationListResource(Resource):
).all(), 200
@requires_auth
@marshal_with_field(Object(resource_fields))
@marshal_with_field(Object(operation_model))
def post(self):
data = parser.parse_args()
@ -90,7 +90,7 @@ class OperationListResource(Resource):
class OperationResource(Resource):
@requires_auth
@marshal_with_field(Object(resource_fields))
@marshal_with_field(Object(operation_model))
def get(self, id):
"""
Get operation.
@ -103,7 +103,7 @@ class OperationResource(Resource):
return operation, 200
@requires_auth
@marshal_with_field(Object(resource_fields))
@marshal_with_field(Object(operation_model))
def post(self, id):
data = parser.parse_args()
@ -124,7 +124,7 @@ class OperationResource(Resource):
return operation, 200
@requires_auth
@marshal_with_field(Object(resource_fields))
@marshal_with_field(Object(operation_model))
def delete(self, id):
operation = db.session.query(Operation).get(id)