Get it to work like this in view.py :

<button onclick="ajax('block_access',[],null);">{{=T('block
access')}}</button>

Thanks Massimo

Is BUTTON helper in trunk??

Richard

On Wed, Feb 9, 2011 at 3:17 PM, Richard Vézina
<ml.richard.vez...@gmail.com>wrote:

> BUTTON not working, but it works without redirection with A(T('block
> access'),_onclick="ajax('%s',[],null);" %
> URL('block_access'))... I don't think that it validate with no _href...
> With _href='' it seems to point on default/index
>
> Richard
>
>
> On Wed, Feb 9, 2011 at 2:49 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> BUTTON Helper do not appear in the book actually...
>>
>> Richard
>>
>>
>> On Wed, Feb 9, 2011 at 2:29 PM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Replace
>>>
>>>
>>> block_access=A(T('block access'),_href=URL(r=request,c='default',
>>> f='block_access'))
>>>
>>> with
>>>
>>>
>>> block_access=BUTTON(T('block access'),_onclick="ajax('%s',[],null);" %
>>> URL('block_access'))
>>>
>>> Mind this will only block login, not users already logged-in, unless
>>> you also clear session.
>>>
>>> On Feb 9, 11:39 am, Richard Vézina <ml.richard.vez...@gmail.com>
>>> wrote:
>>> > Hello,
>>> >
>>> > I would create button to block or unblock user access, so I made those
>>> > function :
>>> >
>>> > def block_access():
>>> >     """
>>> >     UPDATE auth_user
>>> >     SET registration_key='blocked'
>>> >     WHERE auth_user.registration_key = ''
>>> >       AND auth_user.email <> 'myem...@mydomain.com'
>>> >     """
>>> >     db((db.auth_user.registration_key == '') & (db.auth_user.email != '
>>> > myem...@mydomain.com')).update(registration_key='blocked')
>>> >     db.commit()
>>> >
>>> > def unblock_access():
>>> >     """
>>> >     UPDATE auth_user
>>> >     SET registration_key=''
>>> >     WHERE auth_user.registration_key <> 'pending'
>>> >     """
>>> >     db(db.auth_user.registration_key !=
>>> > 'pending').update(registration_key='')
>>> >     db.commit()
>>> >
>>> > Now I would call those function from a link or a button from index or
>>> admin
>>> > dashboard...
>>> >
>>> > I would know if there is a other way except this :
>>> >
>>> > def index():
>>> >     block_access=A(T('block access'),_href=URL(r=request,c='default',
>>> > f='block_access'))
>>> >     unblock_access=A(T('unblock
>>> access'),_href=URL(r=request,c='default',
>>> > f='unblock_access'))
>>> >     return dict(block_access=block_access,
>>> unblock_access=unblock_access)
>>> >
>>> > Since I will need to modify the block and unblock function like this :
>>> >
>>> > def block_access():
>>> >     """
>>> >     UPDATE auth_user
>>> >     SET registration_key='blocked'
>>> >     WHERE auth_user.registration_key = ''
>>> >       AND auth_user.email <> 'myem...@mydomain.com'
>>> >     """
>>> >     db((db.auth_user.registration_key == '') & (db.auth_user.email != '
>>> > myem...@mydomain.com')).update(registration_key='blocked')
>>> >     db.commit()
>>> >     redirect(URL(r=request,c='default', f='index'))
>>> >
>>> > Is there an other way by not utilising redirection?
>>> >
>>> > Thanks
>>> >
>>> > Richard
>>>
>>
>>
>

Reply via email to