Untested:

Something like

roles = [x.role for x in db((db.registration.doctor
==db.auth_membership.user)&
                                      db.auth.membership.user == db.group.id
)
                                    ).select(db.group.role)]
That should give yo a list of roles for db.registration.doctor.

Regards
Johann


On 5 November 2013 08:02, 黄祥 <steve.van.chris...@gmail.com> wrote:

> hi,
>
> is it possible to retrieve auth_group.role from auth_user table?
> e.g.
> # add group
> auth.add_group('Admin', 'Admin')
> auth.add_group('Cashier', 'Cashier')
> auth.add_group('Doctor', 'Doctor')
>
> # add membership (Group, User)
> auth.add_membership('1', '1')
> auth.add_membership('2', '1')
> auth.add_membership('2', '2')
> auth.add_membership('3', '3')
>
> # format_doctor
> def format_doctor(record):
>     return '%s %s' % (record.user_id.first_name, record.user_id.last_name)
>
> # on_define_registration
> def on_define_registration(table):
> # requires
> # table.doctor.requires = IS_IN_DB(db(db.auth_membership.group_id == 3),
> db.auth_user.id,  '%(first_name)s %(last_name)s')
> # table.doctor.requires = IS_IN_DB(db(db.auth_membership.group_id == 3),
> db.auth_membership.id, label = format_doctor)
>
> db.define_table('registration',
> Field('registration_no'),
> Field('registration_date', 'date'),
> Field('patient', 'reference patient'),
> Field('doctor', 'reference auth_user'),
> # Field('doctor', 'reference auth_membership'),
> Field('status'),
> on_define = on_define_registration,
> format = '%(registration_no)s')
>
> how can i retrieve auth_group.role from auth_user table using web2py way?
>
> thanks and best regards,
> stifan
>
> --
> 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.
>



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

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

Reply via email to