# Remove ExternalIdentifier
* adds removing of ExternalIdentifier entries if a BaseObject is removed from the database * removes unused import statements * adds ExternalIdentifier view to admin backend
This commit is contained in:
@@ -146,6 +146,33 @@ class BaseObject(BaseResource, DeletableObjectMixin):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def delete(self, using=None, keep_parents=False):
|
||||
""" Base deleting of a BaseObject instance
|
||||
|
||||
Args:
|
||||
using:
|
||||
keep_parents:
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.__delete_external_identifier()
|
||||
super().delete(using, keep_parents)
|
||||
|
||||
def __delete_external_identifier(self):
|
||||
""" Checks on existing external identifier linking and drops them
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
from api.models import ExternalIdentifier
|
||||
try:
|
||||
external_identifier = ExternalIdentifier.objects.filter(internal_id=self.id)
|
||||
external_identifier.delete()
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def set_status_messages(self, request: HttpRequest):
|
||||
raise NotImplementedError
|
||||
|
||||
Reference in New Issue
Block a user