Add check for linter

This commit is contained in:
zandercymatics 2024-05-06 08:24:00 -06:00
parent 06c605a62f
commit c3db67bf1d
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -1969,8 +1969,13 @@ class Domain(TimeStampedModel, DomainHelper):
# Q: Should we be deleting the newest or the oldest? Does it even matter? # Q: Should we be deleting the newest or the oldest? Does it even matter?
oldest_duplicate = db_contact.order_by("created_at").first() oldest_duplicate = db_contact.order_by("created_at").first()
# Exclude the oldest # The linter wants this check on the id, though in practice
duplicates_to_delete = db_contact.exclude(id=oldest_duplicate.id) # noqa # this should be otherwise impossible.
if hasattr(oldest_duplicate, "id"):
# Exclude the oldest
duplicates_to_delete = db_contact.exclude(id=oldest_duplicate.id)
else:
duplicates_to_delete = db_contact
# Delete all duplicates # Delete all duplicates
duplicates_to_delete.delete() duplicates_to_delete.delete()