Yes, it works perfectly now. Here is my function:
@auth.requires(auth.has_membership('librarian') or 
auth.has_membership('admin'))
def deletesomething():
db(db.auth_membership.id==request.args(0)).delete()
redirect(URL('show_reader', args=request.args(1)), client_side=True)

@auth.requires(auth.has_membership('librarian') or 
auth.has_membership('admin'))
def show_reader():
if request.args(0) and db.auth_user(request.args(0, cast=int)):
user = db.auth_user(request.args(0, cast=int))
form2=''
if (auth.has_membership('admin', user.id) or 
auth.has_membership('librarian', user.id)) and not 
auth.has_membership('admin'):
session.flash = T('Insufficient privileges')
redirect(URL('readers'))
else:
if not auth.has_membership('reader', user.id):
form=FORM(INPUT(_type='submit', _value=T('Activate user')))
if form.process().accepted:
session.flash = T('User has been activated')
db.auth_membership.update_or_insert(user_id=user.id,group_id=auth.id_group('reader'))
redirect(URL('show_reader', args=user.id), client_side=True)
else:
form=FORM(INPUT(_type='submit', _value=T('Deactivate user')))
if form.process().accepted:
session.flash = T('User has been deactivated')
db(db.auth_membership.user_id==user.id).delete()
redirect(URL('show_reader', args=user.id), client_side=True)
if auth.has_membership('admin'):
db.auth_membership.user_id.default=user.id
form2=SQLFORM(db.auth_membership).process()
rows = db(db.auth_membership.user_id==user.id).select()
return locals()
else:
session.flash = T('No such user')
redirect(URL('readers'))
and part of view for show_reader
{{=form}}
{{=form2}}

{{if auth.has_membership('admin'):}}
<table class="table table-striped table-hover">
{{for row in rows:}}
{{qwe=db(db.auth_group.id==row.group_id).select().first()}}
<tr>
<td style="width:15%">{{=T(qwe.role).capitalize()}}</td>
<td><input class="btn" type="submit" value="{{=T('Remove group')}}" 
onclick="ajax('{{=URL('deletesomething',args=[row.id,row.user_id])}}',[],null)"/></td>
</tr>
{{pass}}
</table>
{{pass}}
I know it's sloppy but it's mine :p 
Thanks for all your help, I really appreciate it.



W dniu środa, 4 czerwca 2014 22:48:55 UTC+2 użytkownik LaDarrius Stewart 
napisał:
>
> In what function can you show some new code? And yes do a ajax callback to 
> a delete method.
>
> ex: onclick="ajax('{{=URL('deletesomething',args=(row.id))}}',[],null) (
> row.id could be wrong obv)
>
> def deletesomething():
>     db(db.table.id <http://db.auth_membership.id/>
> ==request.args(0)).delete()
>
> Is this what youre looking for?
>
> This message is for named person(s) only.  It may contain confidential 
> and/or legally privileged information.  No confidentiality or privilege is 
> waived or lost should mis-transmission occur.  If you receive this message 
> in error, delete it (and all copies) and notify the sender.  You must not, 
> directly or indirectly,use, disclose, distribute, print, or copy any part 
> of this message if you are not the intended recipient. GAD GROUP 
> TECHNOLOGY, INC. reserves the right to monitor all e-mail communications 
> through its networks.
>
> Any views expressed in this message are those of the individual sender, 
> except where the message states otherwise and the sender is authorized to 
> state them to be the views of any such entity.
>
> This e-mail has been virus and content scanned by GAD GROUP TECHNOLOGY, 
> INC.
>

-- 
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.

Reply via email to