# HG changeset patch # User Sverre Rabbelier # Date 1223596200 0 # Node ID 651d9eabdef7c3b97d52f54ecd2cf037d7418053 # Parent 1fdaab4a6ef2e02c1419a0ffed888bd98ab5ef55 Removed now-obsolete getAltResponse* methods from simple.py The getAltResponse* methods have been replaced by the check* methods in soc.logic.helper.access. Patch by: Sverre Rabbelier Reviewed by: Pawel Solyga, Augie Fackler, Todd Larsen Reviewed at: http://codereviews.googleopensourceprograms.com/1601 Review id: 1601 diff -r 1fdaab4a6ef2 -r 651d9eabdef7 app/soc/views/simple.py --- a/app/soc/views/simple.py Thu Oct 09 23:48:20 2008 +0000 +++ b/app/soc/views/simple.py Thu Oct 09 23:50:00 2008 +0000 @@ -141,108 +141,3 @@ return helper.responses.respond(request, login_templates, context=context) - -def getAltResponseIfNotLoggedIn(request, context=None, - template=DEF_LOGIN_TMPL, id=None, - login_message_fmt=DEF_LOGIN_MSG_FMT): - """Returns an alternate HTTP response if Google Account is not logged in. - - Args: - request: the standard django request object - context: the context supplied to the template (implements dict) - template: the "sibling" template (or a search list of such templates) - from which to construct the public.html template name (or names) - id: a Google Account (users.User) object, or None, in which case - the current logged-in user is used - - Returns: - None if id is logged in, or a subclass of django.http.HttpResponse - which contains the alternate response that should be returned by the - calling view. - """ - id = id_user.getIdIfMissing(id) - - if id: - # a Google Account is logged in, so no need to ask user to sign in - return None - - # if missing, create default template context for use with any templates - context = helper.responses.getUniversalContext(request, context=context) - - return requestLogin(request, template, context, - login_message_fmt=login_message_fmt) - -DEF_NO_USER_LOGIN_MSG_FMT = ugettext_lazy( - 'Please create User Profile' - ' in order to view this page.') - -def getAltResponseIfNotUser(request, context=None, - template=DEF_LOGIN_TMPL, id=None, - login_message_fmt=DEF_LOGIN_MSG_FMT): - """Returns an alternate HTTP response if Google Account has no User entity. - - Args: - request: the standard django request object - context: the context supplied to the template (implements dict) - template: the "sibling" template (or a search list of such templates) - from which to construct the public.html template name (or names) - id: a Google Account (users.User) object, or None, in which case - the current logged-in user is used - - Returns: - None if User exists for id, or a subclass of django.http.HttpResponse - which contains the alternate response that should be returned by the - calling view. - """ - user_exist = id_user.isIdUser(id) - - if user_exist: - return None - - # if missing, create default template context for use with any templates - context = helper.responses.getUniversalContext(request, context=context) - - return requestLogin(request, template, context, - login_message_fmt=DEF_NO_USER_LOGIN_MSG_FMT) - -DEF_DEV_LOGIN_MSG_FMT = ugettext_lazy( - 'Please sign in' - ' as a site developer to view this page.') - -DEF_DEV_LOGOUT_LOGIN_MSG_FMT = ugettext_lazy( - 'Please sign out' - ' and sign in' - ' again as a site developer to view this page.') - -def getAltResponseIfNotDeveloper(request, context=None, - template=DEF_LOGIN_TMPL, id=None): - """Returns an alternate HTTP response if Google Account is not a Developer. - - Args: - request: the standard django request object - context: the context supplied to the template (implements dict) - template: the "sibling" template (or a search list of such templates) - from which to construct the public.html template name (or names) - id: a Google Account (users.User) object, or None, in which case - the current logged-in user is used - - Returns: - None if id is logged in and logged-in user is a Developer, or a - subclass of django.http.HttpResponse which contains the alternate - response that should be returned by the calling view. - """ - id = id_user.getIdIfMissing(id) - - # if missing, create default template context for use with any templates - context = helper.responses.getUniversalContext(request, context=context) - - if not id: - return requestLogin(request, template, context, - login_message_fmt=DEF_DEV_LOGIN_MSG_FMT) - - if not id_user.isIdDeveloper(id=id): - return requestLogin(request, template, context, - login_message_fmt=DEF_DEV_LOGOUT_LOGIN_MSG_FMT) - - # Google Account is logged in and is a Developer, so no need for sign in - return None