[web2py] Re: Making minor changes to auth.navbar()

2014-06-29 Thread cowbert
It goes into a model file after auth has been instantiated. Everything in 
the model is globalised as models are executed every time the app is 
accessed. Example in db.py:

auth = Auth(db)
...
def user_bar():
   bar = 
   return bar

then you would call user_bar() in place of auth.navbar()

On Tuesday, May 13, 2014 12:21:54 PM UTC-4, Sébastien Loix wrote:
>
> Hello Lewis,
> I am having the same issue. Could you tell us where did you put the code 
> for the navbar?
> Thanks!
> Sebastian
>
> El viernes, 20 de julio de 2012 10:35:25 UTC+2, Matt Newton escribió:
>>
>> Is there a simple way to make changes to the auth.navbar() helper object?
>>
>> For example, the default for a logged in user is:
>>
>> "Welcome {First Name} Logout 
>>  
>> | Profile 
>>  
>> | Password" 
>> 
>>
>> I would like to change it to:
>>
>> '{Email} | Logout | Profile | Password
>>
>> but I'm not sure how to request the information I want when it's masked 
>> by the helper object.
>>
>> Thanks for your help.
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Making minor changes to auth.navbar()

2014-05-13 Thread Sébastien Loix
Hello Lewis,
I am having the same issue. Could you tell us where did you put the code 
for the navbar?
Thanks!
Sebastian

El viernes, 20 de julio de 2012 10:35:25 UTC+2, Matt Newton escribió:
>
> Is there a simple way to make changes to the auth.navbar() helper object?
>
> For example, the default for a logged in user is:
>
> "Welcome {First Name} 
> Logout|
>  
> Profile|
>  
> Password"
>
> I would like to change it to:
>
> '{Email} | Logout | Profile | Password
>
> but I'm not sure how to request the information I want when it's masked by 
> the helper object.
>
> Thanks for your help.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Making minor changes to auth.navbar()

2013-12-05 Thread Rohan Prinja
How did you solve it? I'm facing the same problem - deciding where to place 
the navbar code I wrote.

On Saturday, 15 December 2012 09:09:05 UTC+5:30, Lewis wrote:
>
> I solved this.
>
> On Friday, December 14, 2012 3:37:45 PM UTC-8, Lewis wrote:
>>
>> I understand that code and put it in my controller.
>>
>> But, where do I put the reference to it in the view (the base view that 
>> is extended):
>>
>> By default it says:  {{='auth' in globals() and 
>> auth.navbar(separators=(' ',' | ',''))}}
>>
>> I assume that user.bar must replace auth.navbar(...).
>>
>> But, I don't see how.  An arbitrary function in a controller cannot do 
>> the same things that the auth class method does.  The other problem is that 
>> my user.bar() is not in default so I must also reference the controller 
>> file.  Using URL('...', '') in place of auth.navbar did not work.
>>
>> I am sorry:  when you go mucking about substituting for internal 
>> functions/classes of web2py it is very unclear what one must do because the 
>> behavior of the internal classes is a bit obscure.
>>
>> Thank you.
>>
>> On Friday, July 20, 2012 4:29:37 PM UTC-7, pbreit wrote:
>>>
>>> I just write my own:
>>>
>>> def user_bar():
>>> action = '/user'
>>> if auth.user:
>>> logout=A('logout', _href=action+'/logout')
>>> profile=A('profile', _href=action+'/profile')
>>> password=A('change password', _href=action+'/change_password')
>>> bar = SPAN(auth.user.email, ' | ', profile, ' | ', password, ' 
>>> | ', logout, _class='auth_navbar')
>>> else:
>>> login=A('login', _href=action+'/login')
>>> register=A('register',_href=action+'/register')
>>> lost_password=A('lost password', _href=action+
>>> '/request_reset_password')
>>> bar = SPAN(' ', login, ' | ', register, ' | ', lost_password,_class
>>> ='auth_navbar')
>>> return bar
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Making minor changes to auth.navbar()

2012-12-14 Thread Lewis
I solved this.

On Friday, December 14, 2012 3:37:45 PM UTC-8, Lewis wrote:
>
> I understand that code and put it in my controller.
>
> But, where do I put the reference to it in the view (the base view that is 
> extended):
>
> By default it says:  {{='auth' in globals() and 
> auth.navbar(separators=(' ',' | ',''))}}
>
> I assume that user.bar must replace auth.navbar(...).
>
> But, I don't see how.  An arbitrary function in a controller cannot do the 
> same things that the auth class method does.  The other problem is that my 
> user.bar() is not in default so I must also reference the controller file. 
>  Using URL('...', '') in place of auth.navbar did not work.
>
> I am sorry:  when you go mucking about substituting for internal 
> functions/classes of web2py it is very unclear what one must do because the 
> behavior of the internal classes is a bit obscure.
>
> Thank you.
>
> On Friday, July 20, 2012 4:29:37 PM UTC-7, pbreit wrote:
>>
>> I just write my own:
>>
>> def user_bar():
>> action = '/user'
>> if auth.user:
>> logout=A('logout', _href=action+'/logout')
>> profile=A('profile', _href=action+'/profile')
>> password=A('change password', _href=action+'/change_password')
>> bar = SPAN(auth.user.email, ' | ', profile, ' | ', password, ' | 
>> ', logout, _class='auth_navbar')
>> else:
>> login=A('login', _href=action+'/login')
>> register=A('register',_href=action+'/register')
>> lost_password=A('lost password', _href=action+
>> '/request_reset_password')
>> bar = SPAN(' ', login, ' | ', register, ' | ', lost_password,_class
>> ='auth_navbar')
>> return bar
>>
>>

-- 





[web2py] Re: Making minor changes to auth.navbar()

2012-12-14 Thread Lewis
I understand that code and put it in my controller.

But, where do I put the reference to it in the view (the base view that is 
extended):

By default it says:  {{='auth' in globals() and 
auth.navbar(separators=(' ',' | ',''))}}

I assume that user.bar must replace auth.navbar(...).

But, I don't see how.  An arbitrary function in a controller cannot do the 
same things that the auth class method does.  The other problem is that my 
user.bar() is not in default so I must also reference the controller file. 
 Using URL('...', '') in place of auth.navbar did not work.

I am sorry:  when you go mucking about substituting for internal 
functions/classes of web2py it is very unclear what one must do because the 
behavior of the internal classes is a bit obscure.

Thank you.

On Friday, July 20, 2012 4:29:37 PM UTC-7, pbreit wrote:
>
> I just write my own:
>
> def user_bar():
> action = '/user'
> if auth.user:
> logout=A('logout', _href=action+'/logout')
> profile=A('profile', _href=action+'/profile')
> password=A('change password', _href=action+'/change_password')
> bar = SPAN(auth.user.email, ' | ', profile, ' | ', password, ' | '
> , logout, _class='auth_navbar')
> else:
> login=A('login', _href=action+'/login')
> register=A('register',_href=action+'/register')
> lost_password=A('lost password', _href=action+
> '/request_reset_password')
> bar = SPAN(' ', login, ' | ', register, ' | ', lost_password,_class
> ='auth_navbar')
> return bar
>
>

-- 





[web2py] Re: Making minor changes to auth.navbar()

2012-07-20 Thread pbreit
I just write my own:

def user_bar():
action = '/user'
if auth.user:
logout=A('logout', _href=action+'/logout')
profile=A('profile', _href=action+'/profile')
password=A('change password', _href=action+'/change_password')
bar = SPAN(auth.user.email, ' | ', profile, ' | ', password, ' | 
',logout
, _class='auth_navbar')
else:
login=A('login', _href=action+'/login')
register=A('register',_href=action+'/register')
lost_password=A('lost password', _href=action+
'/request_reset_password')
bar = SPAN(' ', login, ' | ', register, ' | ', lost_password, _class
='auth_navbar')
return bar

-- 





[web2py] Re: Making minor changes to auth.navbar()

2012-07-20 Thread Anthony
Unfortunately, the navbar isn't very flexible. However, it returns an HTML 
helper object (a SPAN with several components), so you can manipulate it 
after creation. The part after "Welcome" is the second component of the 
span, so:

navbar = auth.navbar()
if auth.user:
navbar[1] = auth.user.email #replace first name with email
del navbar[0] # remove "Welcome"

Anthony

On Friday, July 20, 2012 4:35:25 AM UTC-4, Matt Newton wrote:
>
> Is there a simple way to make changes to the auth.navbar() helper object?
>
> For example, the default for a logged in user is:
>
> "Welcome {First Name} 
> Logout|
>  
> Profile|
>  
> Password"
>
> I would like to change it to:
>
> '{Email} | Logout | Profile | Password
>
> but I'm not sure how to request the information I want when it's masked by 
> the helper object.
>
> Thanks for your help.
>

--