diff options
Diffstat (limited to 'servo/models')
-rw-r--r-- | servo/models/account.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/servo/models/account.py b/servo/models/account.py index 2641e81..cb0b82a 100644 --- a/servo/models/account.py +++ b/servo/models/account.py @@ -210,9 +210,41 @@ class User(AbstractUser): def get_icon(self): return 'icon-star' if self.is_staff else 'icon-user' + def get_initials(self): + """ + Returns firstinitiallastinitial + """ + if self.first_name and self.last_name: + return '{0}{1}'.format(self.first_name[0], self.last_name[0]) + + def get_shortname(self): + """Returns Firstname Lastinitial.""" + if self.first_name and self.last_name: + return '{0} {1}.'.format(self.first_name, self.last_name[0]) + def get_name(self): return self.full_name if len(self.full_name) > 1 else self.username + def get_print_name(self): + """ + Returns name of user/tech according to system settings + """ + conf = Configuration.conf('checkin_tech_name') + if conf == 'full': + return self.get_full_name() + + if conf == 'short': + return self.get_shortname() + + if conf == 'first': + return self.first_name + + if conf == 'last': + return self.last_name + + if conf == 'none': + return '' + def get_location(self): return self.location |