mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
Add check for linter
This commit is contained in:
parent
06c605a62f
commit
c3db67bf1d
1 changed files with 7 additions and 2 deletions
|
@ -1969,8 +1969,13 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
# Q: Should we be deleting the newest or the oldest? Does it even matter?
|
||||
oldest_duplicate = db_contact.order_by("created_at").first()
|
||||
|
||||
# Exclude the oldest
|
||||
duplicates_to_delete = db_contact.exclude(id=oldest_duplicate.id) # noqa
|
||||
# The linter wants this check on the id, though in practice
|
||||
# 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
|
||||
duplicates_to_delete.delete()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue