From 11d766d2a4d0ad09866d7bf6bf976d4d6b447d35 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 19 Nov 2020 11:38:41 +0100 Subject: [PATCH] remove deallocate view --- ereuse_devicehub/resources/allocate/views.py | 36 +------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/ereuse_devicehub/resources/allocate/views.py b/ereuse_devicehub/resources/allocate/views.py index 4a368799..d1df9e2a 100644 --- a/ereuse_devicehub/resources/allocate/views.py +++ b/ereuse_devicehub/resources/allocate/views.py @@ -7,7 +7,7 @@ from teal.resource import View from ereuse_devicehub import auth from ereuse_devicehub.db import db from ereuse_devicehub.query import things_response -from ereuse_devicehub.resources.action.models import Allocate, Deallocate +from ereuse_devicehub.resources.action.models import Allocate class AllocateView(View): @@ -41,37 +41,3 @@ class AllocateView(View): """Gets one action.""" allocate = Allocate.query.filter_by(id=id, author=g.user).one() return self.schema.jsonify(allocate, nested=2) - - -class DeAllocateView(View): - @auth.Auth.requires_auth - def get(self, id: uuid.UUID) -> Allocate: - return super().get(id) - - @auth.Auth.requires_auth - def post(self): - """ Create one Deallocate """ - res_json = request.get_json() - deallocate = Deallocate(**res_json) - db.session.add(deallocate) - db.session().final_flush() - ret = self.schema.jsonify(deallocate) - ret.status_code = 201 - db.session.commit() - return ret - - def find(self, args: dict): - deallocates = Deallocate.query.filter_by(author=g.user) \ - .order_by(Deallocate.created.desc()) \ - .paginate(per_page=200) - return things_response( - self.schema.dump(deallocates.items, many=True, nested=0), - deallocates.page, deallocates.per_page, deallocates.total, - deallocates.prev_num, deallocates.next_num - ) - - def one(self, id: uuid.UUID): - """Gets one action.""" - deallocate = Deallocate.query.filter_by(id=id, author=g.user).one() - res = self.schema.jsonify(deallocate, nested=2) - return res