mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 10:29:23 +02:00
Remove submitter from deleting orphaned contacts
This commit is contained in:
parent
d0b3dd7c46
commit
2c43533441
3 changed files with 134 additions and 16 deletions
|
@ -827,18 +827,16 @@ class DomainRequestDeleteView(DomainRequestPermissionDeleteView):
|
|||
|
||||
# Get each contact object on the DomainRequest object
|
||||
so = domain_request.senior_official
|
||||
creator = domain_request.creator
|
||||
other_contacts = list(domain_request.other_contacts.all())
|
||||
other_contact_ids = domain_request.other_contacts.all().values_list("id", flat=True)
|
||||
|
||||
# Check if the desired item still exists in the DB
|
||||
if check_db:
|
||||
so = self._get_contacts_by_id([so.id]).first() if so is not None else None
|
||||
creator = self._get_contacts_by_id([creator.id]).first() if creator is not None else None
|
||||
other_contacts = self._get_contacts_by_id(other_contact_ids)
|
||||
|
||||
# Pair each contact with its db related name for use in checking if it has joins
|
||||
checked_contacts = [(so, "senior_official"), (creator, "submitted_domain_requests")]
|
||||
checked_contacts = [(so, "senior_official")]
|
||||
checked_contacts.extend((contact, "contact_domain_requests") for contact in other_contacts)
|
||||
|
||||
for contact, related_name in checked_contacts:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue