##// END OF EJS Templates
Implemented #532....
marcink -
r2731:09d8fec0 beta
parent child Browse files
Show More
@@ -416,9 +416,9 b' def email_or_none(author):'
416 return None
416 return None
417
417
418
418
419 def person(author):
419 def person(author, show_attr="username_and_name"):
420 # attr to return from fetched user
420 # attr to return from fetched user
421 person_getter = lambda usr: usr.username
421 person_getter = lambda usr: getattr(usr, show_attr)
422
422
423 # Valid email in the attribute passed, see if they're in the system
423 # Valid email in the attribute passed, see if they're in the system
424 _email = email(author)
424 _email = email(author)
@@ -439,9 +439,9 b' def person(author):'
439 return _author
439 return _author
440
440
441
441
442 def person_by_id(id_):
442 def person_by_id(id_, show_attr="username_and_name"):
443 # attr to return from fetched user
443 # attr to return from fetched user
444 person_getter = lambda usr: usr.username
444 person_getter = lambda usr: getattr(usr, show_attr)
445
445
446 #maybe it's an ID ?
446 #maybe it's an ID ?
447 if str(id_).isdigit() or isinstance(id_, int):
447 if str(id_).isdigit() or isinstance(id_, int):
@@ -330,26 +330,35 b' class User(Base, BaseModel):'
330 self._email = val.lower() if val else None
330 self._email = val.lower() if val else None
331
331
332 @property
332 @property
333 def firstname(self):
334 # alias for future
335 return self.name
336
337 @property
333 def emails(self):
338 def emails(self):
334 other = UserEmailMap.query().filter(UserEmailMap.user==self).all()
339 other = UserEmailMap.query().filter(UserEmailMap.user==self).all()
335 return [self.email] + [x.email for x in other]
340 return [self.email] + [x.email for x in other]
336
341
337 @property
342 @property
343 def username_and_name(self):
344 return '%s (%s %s)' % (self.username, self.firstname, self.lastname)
345
346 @property
338 def full_name(self):
347 def full_name(self):
339 return '%s %s' % (self.name, self.lastname)
348 return '%s %s' % (self.firstname, self.lastname)
340
349
341 @property
350 @property
342 def full_name_or_username(self):
351 def full_name_or_username(self):
343 return ('%s %s' % (self.name, self.lastname)
352 return ('%s %s' % (self.firstname, self.lastname)
344 if (self.name and self.lastname) else self.username)
353 if (self.firstname and self.lastname) else self.username)
345
354
346 @property
355 @property
347 def full_contact(self):
356 def full_contact(self):
348 return '%s %s <%s>' % (self.name, self.lastname, self.email)
357 return '%s %s <%s>' % (self.firstname, self.lastname, self.email)
349
358
350 @property
359 @property
351 def short_contact(self):
360 def short_contact(self):
352 return '%s %s' % (self.name, self.lastname)
361 return '%s %s' % (self.firstname, self.lastname)
353
362
354 @property
363 @property
355 def is_admin(self):
364 def is_admin(self):
General Comments 0
You need to be logged in to leave comments. Login now