Add a normalizeAccount to logic.accounts
authorSverre Rabbelier <srabbelier@gmail.com>
Thu, 26 Feb 2009 16:54:08 +0000
changeset 1520 ac407f5b10dc
parent 1519 eb70b27696de
child 1521 bb086732bf7f
Add a normalizeAccount to logic.accounts Patch by: Sverre Rabbelier
app/soc/logic/accounts.py
--- a/app/soc/logic/accounts.py	Thu Feb 26 16:53:36 2009 +0000
+++ b/app/soc/logic/accounts.py	Thu Feb 26 16:54:08 2009 +0000
@@ -30,6 +30,17 @@
 import soc.logic.models.user
 
 
+def normalizeAccount(account):
+  """Returns a normalized version of the specified account.
+  """
+
+  normalized = str(account).lower()
+
+  if account.email() == normalized:
+    return account
+
+  return users.User(email=normalized)
+
 def isDeveloper(account=None, user=None):
   """Returns True if a Google Account is a Developer with special privileges.