Fix signals bug

This commit is contained in:
zandercymatics 2023-12-19 14:59:47 -07:00
parent c01b4ea750
commit 4378816cdf
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 4 additions and 4 deletions

View file

@ -59,12 +59,12 @@ class Contact(TimeStampedModel):
names = [n for n in [self.first_name, self.middle_name, self.last_name] if n]
return " ".join(names) if names else "Unknown"
def save(self, *args, **kwargs):
def save(self, enable_custom_save=True, *args, **kwargs):
# Call the parent class's save method to perform the actual save
super().save(*args, **kwargs)
# Update the related User object's first_name and last_name
if self.user:
if self.user and enable_custom_save:
self.user.first_name = self.first_name
self.user.last_name = self.last_name
self.user.save()

View file

@ -46,7 +46,7 @@ def handle_profile(sender, instance, **kwargs):
if len(contacts) >= 1 and is_new_user: # a matching contact
contacts[0].user = instance
contacts[0].save()
contacts[0].save(enable_custom_save=False)
if len(contacts) > 1: # multiple matches
logger.warning(

View file

@ -235,7 +235,7 @@ class AuditedAdminMockData:
def dummy_contact(self, item_name, short_hand):
"""Creates a dummy contact object"""
contact = Contact.objects.get_or_create(
first_name="{} first_name:{}".format(item_name + "fake_contact", short_hand),
first_name="{} first_name:{}".format(item_name, short_hand),
last_name="{} last_name:{}".format(item_name, short_hand),
title="{} title:{}".format(item_name, short_hand),
email="{}testy@town.com".format(item_name),