Merge pull request #18034 from edx/roux/fix-deletable-by-user-value

Changes the DeletableByUserValue delete algorithm.
This commit is contained in:
Alessandro Roux
2018-04-24 13:57:33 -04:00
committed by GitHub

View File

@@ -32,5 +32,10 @@ class DeletableByUserValue(object):
Returns False otherwise.
"""
filter_kwargs = {field: value}
num_deleted_records, _ = cls.objects.filter(**filter_kwargs).delete()
return num_deleted_records > 0
records_matching_user_value = cls.objects.filter(**filter_kwargs)
if not records_matching_user_value.exists():
return False
records_matching_user_value.delete()
return True