On 13 November 2012 19:04, John Ho <[email protected]> wrote:

> For a school admin database, different roles for logged in users:  admin,
> teachers and staff.  I can use using auth_group and auth_membership to
> define these roles.
>
> I have the following table:
>
> db.define_table( "class", Field("teacher_id", db.auth_user), ...)
>
> want a form to create a new class, very nice that web2py will done most of
> the work of creating a form with drop-down list of auth_users for the
> "teacher_id" field.  However, I don't want the whole list of auth_users, I
> would like the list to be filtered to only show users with "teacher" role.
>
> I think using the _and=IS_IN_DB() to get the subset, not quite sure how to
> write it.
>
>
One option is to build a set with a separate query and use IS_IN_SET()

Something like

teachers = [x.teacher_id for x in db(class.teacher_id >
0).select(db.class.teacher_id)

and then IS_IN_SET(teachers)

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

-- 



Reply via email to