referrer_actions, thanks Anthony

This commit is contained in:
mdipierro
2012-07-06 11:47:25 -05:00
parent c0cc76ae93
commit 84d4359fd1
2 changed files with 23 additions and 10 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-07-06 11:31:58) dev
Version 2.00.0 (2012-07-06 11:47:22) dev
+22 -9
View File
@@ -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: