From 775cd9a215e8a982ca19b307aa9d2c88addff163 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Sat, 21 Nov 2020 15:52:29 +0100 Subject: [PATCH] fixing bugs --- ereuse_devicehub/resources/action/schemas.py | 6 +++++- ereuse_devicehub/resources/allocate/views.py | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index 8534b8f7..0ac2586e 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -69,13 +69,17 @@ class Allocate(ActionWithMultipleDevices): description = SanitizedStr(default='', description=m.Action.description.comment) start_time = DateTime(data_key='start_time', description=m.Action.start_time.comment) end_time = DateTime(data_key='end_time', description=m.Action.end_time.comment) - code = SanitizedStr(validate=Length(min=1, max=STR_BIG_SIZE), + code = SanitizedStr(data_key='Transaction', validate=Length(min=1, max=STR_BIG_SIZE), required=False, description='The code of the agent to assigned.') end_users = Integer(validate=[Range(min=1, error="Value must be greater than 0")], required=True) +class Deallocate(ActionWithMultipleDevices): + __doc__ = m.Deallocate.__doc__ + + class EraseBasic(ActionWithOneDevice): __doc__ = m.EraseBasic.__doc__ steps = NestedOn('Step', many=True) diff --git a/ereuse_devicehub/resources/allocate/views.py b/ereuse_devicehub/resources/allocate/views.py index 7864fe62..cd044203 100644 --- a/ereuse_devicehub/resources/allocate/views.py +++ b/ereuse_devicehub/resources/allocate/views.py @@ -12,7 +12,7 @@ class AllocateMix(): def post(self): """ Create one res_obj """ res_json = request.get_json() - res_obj = model(**res_json) + res_obj = self.model(**res_json) db.session.add(res_obj) db.session().final_flush() ret = self.schema.jsonify(res_obj) @@ -21,8 +21,8 @@ class AllocateMix(): return ret def find(self, args: dict): - res_objs = model.query.filter_by(author=g.user) \ - .order_by(model.created.desc()) \ + res_objs = self.model.query.filter_by(author=g.user) \ + .order_by(self.model.created.desc()) \ .paginate(per_page=200) return things_response( self.schema.dump(res_objs.items, many=True, nested=0), @@ -31,9 +31,9 @@ class AllocateMix(): ) -class AllocateView(AllocateMix): +class AllocateView(AllocateMix, View): model = Allocate -class DeallocateView(AllocateMix): +class DeallocateView(AllocateMix, View): model = Deallocate