From 84d4359fd1821872cab1e45a2af723ad47ac4e3a Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 6 Jul 2012 11:47:25 -0500 Subject: [PATCH] referrer_actions, thanks Anthony --- VERSION | 2 +- gluon/tools.py | 31 ++++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 1fcd094b..2ac640e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-07-06 11:31:58) dev +Version 2.00.0 (2012-07-06 11:47:22) dev diff --git a/gluon/tools.py b/gluon/tools.py index 4badf487..a0bfa75b 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -1209,7 +1209,13 @@ class Auth(object): else: raise HTTP(404) - def navbar(self, prefix='Welcome', action=None, separators=(' [ ',' | ',' ] ')): + def navbar(self, prefix='Welcome', action=None, + separators=(' [ ',' | ',' ] '), + referrer_actions=DEFAULT): + if referrer_actions == DEFAULT: + referrer_actions = ['login','logout','profile', + 'register','change_password', + 'retrieve_username','request_reset_password'] request = current.request T = current.T if isinstance(prefix,str): @@ -1224,13 +1230,20 @@ class Auth(object): else: next = '?_next='+urllib.quote(URL(args=request.args,vars=request.get_vars)) - li_next = '?_next='+urllib.quote(self.settings.login_next) - lo_next = '?_next='+urllib.quote(self.settings.logout_next) - + pr_next = next if 'profile' in referrer_actions else '' + pa_next = next if 'change_password' in referrer_actions else '' + re_next = next if 'register' in referrer_actions else '' + ru_next = next if 'retrieve_username' in referrer_actions else '' + rp_next = next if 'request_reset_password' in referrer_actions else '' + li_next = '?_next='+urllib.quote(self.settings.login_next) \ + if 'login' in referrer_actions else '' + lo_next = '?_next='+urllib.quote(self.settings.logout_next) \ + if 'logout' in referrer_actions else '' + if self.user_id: logout=A(T('Logout'),_href=action+'/logout'+lo_next) - profile=A(T('Profile'),_href=action+'/profile'+next) - password=A(T('Password'),_href=action+'/change_password'+next) + profile=A(T('Profile'),_href=action+'/profile'+pr_next) + password=A(T('Password'),_href=action+'/change_password'+pa_next) bar = SPAN(prefix,self.user.first_name,s1, logout,s3,_class='auth_navbar') if not 'profile' in self.settings.actions_disabled: bar.insert(4, s2) @@ -1240,11 +1253,11 @@ class Auth(object): bar.insert(-1, password) else: login=A(T('Login'),_href=action+'/login'+li_next) - register=A(T('Register'),_href=action+'/register'+next) + register=A(T('Register'),_href=action+'/register'+re_next) retrieve_username=A(T('forgot username?'), - _href=action+'/retrieve_username'+next) + _href=action+'/retrieve_username'+ru_next) lost_password=A(T('Lost password?'), - _href=action+'/request_reset_password'+next) + _href=action+'/request_reset_password'+ru_next) bar = SPAN(s1, login, s3, _class='auth_navbar') if not 'register' in self.settings.actions_disabled: