From 5e35df7b48b43c08851e7aacbe5390689280ef9c Mon Sep 17 00:00:00 2001 From: Megan Henning <meganhenning@flywheel.io> Date: Thu, 11 Jan 2018 12:09:22 -0600 Subject: [PATCH] Don't return delete objs in consistency check --- api/dao/consistencychecker.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/api/dao/consistencychecker.py b/api/dao/consistencychecker.py index 62104d7e..7b6eea86 100644 --- a/api/dao/consistencychecker.py +++ b/api/dao/consistencychecker.py @@ -23,10 +23,6 @@ def get_container_storage_checker(action, cont_name): return field_on_container('acquisition', 'acquisitions') elif cont_name == 'groups' and action == 'DELETE': return check_children('group', 'projects') - elif cont_name == 'projects' and action == 'DELETE': - return check_children('project', 'sessions') - elif cont_name == 'sessions' and action == 'DELETE': - return check_children('session', 'acquisitions') return noop def user_on_permission(data_op, **kwargs): # pylint: disable=unused-argument @@ -64,7 +60,7 @@ def check_children(foreign_key_field, container_name): APIConsistencyException: Child document found """ def f(data_op, **kwargs): # pylint: disable=unused-argument - if config.db[container_name].find_one({foreign_key_field: data_op['_id']}): + if config.db[container_name].find_one({foreign_key_field: data_op['_id'], 'deleted' :{'$exists': False}}): raise APIConsistencyException( 'DELETE not allowed. Children {} found for {}'.format(container_name, data_op['_id']) ) -- GitLab