Do not display nickname or initials as none

parent 85a6f424
...@@ -313,13 +313,15 @@ class Member(models.Model): ...@@ -313,13 +313,15 @@ class Member(models.Model):
def display_name(self): def display_name(self):
pref = self.display_name_preference pref = self.display_name_preference
if pref == 'nickname': if pref == 'nickname' and self.nickname is not None:
return self.nickname return self.nickname
if pref == 'firstname': if pref == 'firstname':
return self.user.first_name return self.user.first_name
elif pref == 'initials': elif pref == 'initials':
return '{} {}'.format(self.initials, self.user.last_name) if self.initials:
elif pref == 'fullnick': return '{} {}'.format(self.initials, self.user.last_name)
return self.user.last_name
elif pref == 'fullnick' and self.nickname is not None:
return "{} '{}' {}".format(self.user.first_name, return "{} '{}' {}".format(self.user.first_name,
self.nickname, self.nickname,
self.user.last_name) self.user.last_name)
...@@ -332,10 +334,13 @@ class Member(models.Model): ...@@ -332,10 +334,13 @@ class Member(models.Model):
def short_display_name(self): def short_display_name(self):
pref = self.display_name_preference pref = self.display_name_preference
if pref == 'nickname' or pref == 'nicklast': if (self.nickname is not None and
(pref == 'nickname' or pref == 'nicklast')):
return self.nickname return self.nickname
elif pref == 'initials': elif pref == 'initials':
return '{} {}'.format(self.initials, self.user.last_name) if self.initials:
return '{} {}'.format(self.initials, self.user.last_name)
return self.user.last_name
else: else:
return self.user.first_name return self.user.first_name
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment