# 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:
2026-08-17 14:35:42 +02:00
parent ea1276e40b
commit 6772ddb5c8
4 changed files with 41 additions and 4 deletions
+27
View File
@@ -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