update for code clarity

This commit is contained in:
David Kennedy 2024-01-10 14:35:52 -05:00
parent bf5867ffc9
commit 3a221ce1cc
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B

View file

@ -96,7 +96,7 @@ class RegistrarFormSet(forms.BaseFormSet):
""" """
raise NotImplementedError raise NotImplementedError
def test_if_more_than_one_join(self, db_obj, rel, related_name): def has_more_than_one_join(self, db_obj, rel, related_name):
"""Helper for finding whether an object is joined more than once.""" """Helper for finding whether an object is joined more than once."""
# threshold is the number of related objects that are acceptable # threshold is the number of related objects that are acceptable
# when determining if related objects exist. threshold is 0 for most # when determining if related objects exist. threshold is 0 for most
@ -165,7 +165,7 @@ class RegistrarFormSet(forms.BaseFormSet):
# matching database object exists, update it # matching database object exists, update it
if db_obj is not None and cleaned: if db_obj is not None and cleaned:
if should_delete(cleaned): if should_delete(cleaned):
if any(self.test_if_more_than_one_join(db_obj, rel, related_name) for rel in reverse_joins): if any(self.has_more_than_one_join(db_obj, rel, related_name) for rel in reverse_joins):
# Remove the specific relationship without deleting the object # Remove the specific relationship without deleting the object
getattr(db_obj, related_name).remove(self.application) getattr(db_obj, related_name).remove(self.application)
else: else: