Allows a user object to be passed to accounts.isDeveloper
This saves a trip to the database if the user object has already
been retrieved.
Patch by: Sverre Rabbelier
--- a/app/soc/logic/accounts.py Fri Dec 12 00:35:08 2008 +0000
+++ b/app/soc/logic/accounts.py Fri Dec 12 00:35:28 2008 +0000
@@ -31,7 +31,7 @@
import soc.logic.models.user
-def isDeveloper(account=None):
+def isDeveloper(account=None, user=None):
"""Returns True if a Google Account is a Developer with special privileges.
Since it only works on the current logged-in user, if account matches the
@@ -48,6 +48,9 @@
the current logged-in user is checked
"""
+ if user and (not account):
+ account = user.account
+
# Get the currently logged in user
current = users.get_current_user()
@@ -65,7 +68,8 @@
if not account:
account = current
- user = models.user.logic.getForFields({'account': account}, unique=True)
+ if not user:
+ user = models.user.logic.getForFields({'account': account}, unique=True)
if not user:
# no User entity for this Google Account, and account is not the