aboutsummaryrefslogtreecommitdiffstats
path: root/servo/models
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2021-06-17 20:49:00 +0300
committerFilipp Lepalaan <filipp@mac.com>2021-06-17 20:49:00 +0300
commit3418ece690ca90d676a7d8ae654da7770ae312fb (patch)
tree5daa04838cda0e85da32865fde42b14f310a2627 /servo/models
parent3421b809f432ee49586df91b627ef70aa3e07cbf (diff)
downloadServo-master.tar.gz
Servo-master.tar.bz2
Servo-master.zip
Add print options for tech nameHEADmaster
Diffstat (limited to 'servo/models')
-rw-r--r--servo/models/account.py32
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