# HG changeset patch # User Todd Larsen # Date 1221251516 0 # Node ID 0f572149449dd581d138185afd2ed59cf393b622 # Parent a95f511bfcf8ab57517c39426fbfa9f2bf063174 Make isIdDeveloper() also able to check an is_developer Boolean property in User entities. Review URL: http://codereviews.googleopensourceprograms.com/601 diff -r a95f511bfcf8 -r 0f572149449d app/soc/logic/site/id_user.py --- a/app/soc/logic/site/id_user.py Fri Sep 12 19:01:44 2008 +0000 +++ b/app/soc/logic/site/id_user.py Fri Sep 12 20:31:56 2008 +0000 @@ -139,21 +139,34 @@ def isIdDeveloper(id=None): """Returns True if Google Account is a Developer with special privileges. + using the App Engine Users API. + Args: id: a Google Account (users.User) object; if id is not supplied, - the current logged-in user is checked using the App Engine Users API. - THIS ARGUMENT IS CURRENTLY IGNORED AND ONLY THE CURRENTLY LOGGED-IN - USER IS CHECKED! - - See the TODO in the code below... + the current logged-in user is checked """ + id = getIdIfMissing(id) + if not id: - return users.is_current_user_admin() + # no Google Account was supplied or is logged in, so an unspecified + # User is definitely *not* a Developer + return False - # TODO(tlarsen): this Google App Engine function only checks the currently - # logged in user. There needs to be another way to do this, such as a - # field in the User Model... - return users.is_current_user_admin() + if id == users.get_current_user(): + if users.is_current_user_admin(): + # supplied id is current logged-in user, and that user is in the + # Administration->Developers list in the App Engine console + return True + + user = getUserFromId(id) + + if not user: + # no User entity for this Google Account, and id is not the currently + # logged-in user, so there is no conclusive way to check the + # Administration->Developers list in the App Engine console + return False + + return user.is_developer LINKNAME_PATTERN = r'''(?x) diff -r a95f511bfcf8 -r 0f572149449d app/soc/models/user.py --- a/app/soc/models/user.py Fri Sep 12 19:01:44 2008 +0000 +++ b/app/soc/models/user.py Fri Sep 12 20:31:56 2008 +0000 @@ -75,3 +75,9 @@ link_name.help_text = ugettext_lazy( 'Field used in URLs to identify user. ' 'Lower ASCII characters only.') + + #: field storing whether User is a Developer with site-wide access. + is_developer = db.BooleanProperty( + verbose_name=ugettext_lazy('Is Developer')) + is_developer.help_text = ugettext_lazy( + 'Field used to indicate user with site-wide "Developer" access.') diff -r a95f511bfcf8 -r 0f572149449d app/soc/templates/soc/site/user/profile/lookup.html --- a/app/soc/templates/soc/site/user/profile/lookup.html Fri Sep 12 19:01:44 2008 +0000 +++ b/app/soc/templates/soc/site/user/profile/lookup.html Fri Sep 12 20:31:56 2008 +0000 @@ -37,6 +37,12 @@ {{ found_user.nick_name }}   + + Is Developer +   + {{ found_user.is_developer }} +   + {% endif %}   diff -r a95f511bfcf8 -r 0f572149449d app/soc/views/user/profile.py --- a/app/soc/views/user/profile.py Fri Sep 12 19:01:44 2008 +0000 +++ b/app/soc/views/user/profile.py Fri Sep 12 20:31:56 2008 +0000 @@ -49,7 +49,7 @@ model = soc.models.user.User #: list of model fields which will *not* be gathered by the form - exclude = ['id', 'former_ids'] + exclude = ['id', 'former_ids', 'is_developer'] def clean_link_name(self): link_name = self.cleaned_data.get('link_name')