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 <> '[email protected]'
"""
db((db.auth_user.registration_key == '') & (db.auth_user.email != '
[email protected]')).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 <> '[email protected]'
"""
db((db.auth_user.registration_key == '') & (db.auth_user.email != '
[email protected]')).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