Can anybody help me? I still can't figure it out on my own... W dniu niedziela, 1 czerwca 2014 16:10:07 UTC+2 użytkownik john smith napisał: > > I want to create a page that will display user data, with additional > controls. I want librarian to be able to add user to 'readers' and remove > group, that part works. I also want admin be able to freely manage groups > of a user, I want him to have a widget that will have a list of groups with > submit button that will add user to selected group, and list of all groups > user is a member of with ability to remove him from those. I have 3 > problems with that: > 1. I don't know how to create form that will display drop-down list with > groups, like SQLFORM does. I could replace it with SQLFORM but then I need > to know how to hide user_id field and set it to user.id value > 2. Even when click submit button of form2, action of form is executed. > 3. SQLFORM.grid won't let me access the view, i get flash with 'not > authorized' message. > Here is my code: > @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') > #user.registration_key='blocked' > #user.update_record(registration_key='blocked') > db(db.auth_membership.user_id==user.id).delete() > redirect(URL('show_reader', args=user.id), client_side=True) > if auth.has_membership('admin'): > #form2='' > form2=FORM('Your name:', > INPUT(_name='grupa', _type='text'), > INPUT(_type='submit')) > if form2.process().accepted: > redirect(URL('index')) > form3=SQLFORM.grid(db.auth_membership.user_id==user.id, deletable=False, > editable=False, create=False, details=False) > > return locals() > else: > session.flash = T('No such user') > redirect(URL('readers')) > > > > >
-- 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.