# HG changeset patch # User Sverre Rabbelier # Date 1235667361 0 # Node ID 1e6ac8f61a97b84151a35dd9860b328e2acc99d9 # Parent 983b126f5aca353bd657553d2970f697ca3014cb Added an isDeveloper method to user logic Patch by: Sverre Rabbelier diff -r 983b126f5aca -r 1e6ac8f61a97 app/soc/logic/models/user.py --- a/app/soc/logic/models/user.py Thu Feb 26 16:55:23 2009 +0000 +++ b/app/soc/logic/models/user.py Thu Feb 26 16:56:01 2009 +0000 @@ -94,6 +94,28 @@ return self.getForFields(filter=fields, unique=True) + def isDeveloper(self, account=None, user=None): + """Returns true iff the specified user is a Developer. + + Args: + account: if not supplied, defaults to the current account + user: if not specified, defaults to the current user + """ + + if not account: + # default account to the current logged in account + account = users.get_current_user() + + if account and (not user): + # default user to the current logged in user + user = self.getForAccount(account) + + if user: + return user.is_developer + + if account and (account == users.get_current_user()): + return users.is_current_user_admin() + def agreesToSiteToS(self, entity): """Returns indication of User's answer to the site-wide Terms of Service.