Added getForCurrentAccount to user.Logic
It returns the user entity associated with the currently logged in
user.
Patch by: Sverre Rabbelier
--- a/app/soc/logic/models/user.py Fri Dec 12 00:34:12 2008 +0000
+++ b/app/soc/logic/models/user.py Fri Dec 12 00:34:39 2008 +0000
@@ -22,6 +22,8 @@
]
+from google.appengine.api import users
+
from soc.logic.helper import notifications
from soc.logic.models import base
@@ -54,6 +56,22 @@
return False
+ def getForCurrentAccount(self):
+ """Retrieves the user entity for the currently logged in account
+
+ If there is no user logged in, or they have no associated User
+ entity, None is returend.
+ """
+
+ account = users.get_current_user()
+
+ if not account:
+ return None
+
+ user = self.getForFields({'account': account}, unique=True)
+
+ return user
+
def getKeyValues(self, entity):
"""See base.Logic.getKeyValues.
"""