# HG changeset patch # User Sverre Rabbelier # Date 1229042128 0 # Node ID b26295df0d9a8ef3327ec670e0838164ed07c87e # Parent 69e5130e4a0a265f447ebe2347ce96a3b369d98d 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 diff -r 69e5130e4a0a -r b26295df0d9a app/soc/logic/accounts.py --- 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