changeset 87:6a52c9c3d5ff

Add 'emailaddr' property to User class.
author Daniele Nicolodi <daniele@grinta.net>
date Sun, 21 Aug 2011 18:17:26 +0200
parents 5c567edc0e6c
children 7d03f602cade
files src/ltpdarepo/user.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ltpdarepo/user.py	Sun Aug 21 18:17:12 2011 +0200
+++ b/src/ltpdarepo/user.py	Sun Aug 21 18:17:26 2011 +0200
@@ -1,3 +1,5 @@
+from email.utils import formataddr
+
 from flask import g
 from wtforms import validators
 from wtforms.fields import TextField, PasswordField, BooleanField
@@ -65,6 +67,11 @@
     def __getitem__(self, name):
         return getattr(self, name)
 
+    @property
+    def emailaddr(self):
+        # user email address in the form 'Name Surname <email>'
+        return formataddr(('%s %s' % (self.name, self.surname), self.email))
+
     @staticmethod
     def load(username):
         curs = g.db.cursor(DictCursor)