Skip to content

Commit

Permalink
personal: Add Contact string represeantation
Browse files Browse the repository at this point in the history
Change default string representation from "Dr. Henry Jeckyl" to "Jekyll,
Henry".

Add property method "name" to return the same representation.

Add property name_and_title to return name with title(s) included
("Jekyll, Dr. Henry, PhD MD")
  • Loading branch information
donald committed Feb 9, 2025
1 parent 879cabe commit 5f181a8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mpicms/personal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,21 @@ class Contact(index.Indexed, models.Model):
# index.SearchField('groups'),
]

@property
def name(self):
return ", ".join(filter(None, (self.last_name, self.first_name)))

@property
def name_and_title(self):
return ", ".join(filter(None, (
self.last_name,
" ".join(filter(None, (self.title, self.first_name))),
self.academic_suffix,
)))

def __str__(self):
if self.first_name or self.last_name:
return " ".join(filter(None, (self.title, self.first_name, self.last_name)))
return ", ".join(filter(None, (self.last_name, self.first_name)))
else:
return self.email

Expand Down

0 comments on commit 5f181a8

Please sign in to comment.