From ed2ee391486014400a5fdaa2d8594324142f6f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20S=C3=A1nchez?= Date: Tue, 25 May 2021 17:55:10 -0500 Subject: [PATCH] Validations --- fast_agave/blueprints/rest_api.py | 10 +++++++--- fast_agave/version.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fast_agave/blueprints/rest_api.py b/fast_agave/blueprints/rest_api.py index dabcdab..1cafcd4 100644 --- a/fast_agave/blueprints/rest_api.py +++ b/fast_agave/blueprints/rest_api.py @@ -26,7 +26,7 @@ async def retrieve_object( self, resource_class: Any, resource_id: str ) -> Any: query = Q(id=resource_id) - if self.user_id_filter_required(): + if self.user_id_filter_required() and hasattr(resource_class.model, 'user_id'): query = query & Q(user_id=self.current_user_id) try: data = await resource_class.model.objects.async_get(query) @@ -73,8 +73,12 @@ def wrapper_resource_class(cls): Use "delete" method (if exists) to create the FastApi endpoint """ if hasattr(cls, 'delete'): - route = self.delete(path + '/{id}') - route(cls.delete) + + @self.delete(path + '/{id}') + @copy_attributes(cls) + async def delete(id: str): + obj = await self.retrieve_object(cls, id) + return await cls.delete(obj) """ PATCH /resource/{id} Enable PATCH method if Resource.update method exist. It validates diff --git a/fast_agave/version.py b/fast_agave/version.py index cc884bb..a4eb227 100644 --- a/fast_agave/version.py +++ b/fast_agave/version.py @@ -1 +1 @@ -__version__ = '0.0.2.dev3' +__version__ = '0.0.2.dev4'