mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-04 18:23:29 +02:00
Contact saves update the corresponding user's first and last names
This commit is contained in:
parent
e4803d6afd
commit
ae811d16a9
1 changed files with 10 additions and 0 deletions
|
@ -59,6 +59,16 @@ class Contact(TimeStampedModel):
|
||||||
names = [n for n in [self.first_name, self.middle_name, self.last_name] if n]
|
names = [n for n in [self.first_name, self.middle_name, self.last_name] if n]
|
||||||
return " ".join(names) if names else "Unknown"
|
return " ".join(names) if names else "Unknown"
|
||||||
|
|
||||||
|
def save(self, *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:
|
||||||
|
self.user.first_name = self.first_name
|
||||||
|
self.user.last_name = self.last_name
|
||||||
|
self.user.save()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.first_name or self.last_name:
|
if self.first_name or self.last_name:
|
||||||
return self.get_formatted_name()
|
return self.get_formatted_name()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue