Add exceptions.DeletedObject and ObjectBase.assert_not_deleted.

This commit is contained in:
voussoir 2020-09-20 11:31:51 -07:00
parent 85260144ef
commit b66464dc46
2 changed files with 10 additions and 0 deletions

View file

@ -181,6 +181,12 @@ class DatabaseOutOfDate(EtiquetteException):
''' '''
error_message = OUTOFDATE error_message = OUTOFDATE
class DeletedObject(EtiquetteException):
'''
For when thing.deleted == True.
'''
error_message = '{} has already been deleted by another caller.'
class FeatureDisabled(EtiquetteException): class FeatureDisabled(EtiquetteException):
''' '''
For when features of the system have been disabled by the configuration. For when features of the system have been disabled by the configuration.

View file

@ -68,6 +68,10 @@ class ObjectBase:
return author_id return author_id
def assert_not_deleted(self):
if self.deleted:
raise exceptions.DeletedObject(self)
def get_author(self): def get_author(self):
''' '''
Return the User who created this object, or None if it is unassigned. Return the User who created this object, or None if it is unassigned.