Make common typeclass.delete return True/False to match Object.delete api for consistency. Resolve #2398

This commit is contained in:
Griatch 2021-11-03 23:18:50 +01:00
parent 00b29a693d
commit 58f86fd3d7
4 changed files with 38 additions and 5 deletions

View file

@ -853,6 +853,12 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
`*args` and `**kwargs` are passed on to the base delete
mechanism (these are usually not used).
Return:
bool: If deletion was successful. Only time it fails would be
if the Account was already deleted. Note that even on a failure,
connected resources (nicks/aliases etc) will still have been
deleted.
"""
for session in self.sessions.all():
# unpuppeting all objects and disconnecting the user, if any
@ -868,7 +874,11 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
self.attributes.clear()
self.nicks.clear()
self.aliases.clear()
if not self.pk:
return False
super().delete(*args, **kwargs)
return True
# methods inherited from database model