I'm trying to determine the best way to code the following situation in 
web2py.

Currently I have a model that has this in it:

db.define_table('ingredient',
                Field('ingredient_name', 'string', required=True),
                Field('kind_ref', 'reference kind', required=True, 
requires=IS_IN_DB(db, 'kind.id','%(kind_name)s')),
                Field('type_ref', 'reference ingredient_type', 
required=True, requires=IS_IN_DB(db, 'ingredient_type.id','%(type_name)s')),
                Field('subtype_ref', 'reference ingredient_subtype', 
required=True, requires=IS_IN_DB(db, 
'ingredient_subtype.id','%(subtype_name)s')),
                Field('brand_ref', 'reference ingredient_brand', 
required=True, requires=IS_IN_DB(db, 
'ingredient_brand.id','%(brand_name)s')),
                Field('is_approved', 'boolean', default=True),
                Field('for_match', 'boolean', default=True),
                Field('ingredient_so', 'integer', default=50),
                format='%(ingredient_name)s'
                )

db.define_table('drink_recipe_ingredients',
                Field('drink_recipe_ref', 'reference drink_recipe', 
requires=IS_IN_DB(db, 'drink_recipe.id','%(drink_recipe_name)s')),
                Field('ingredient_ref', 'reference ingredient', 
requires=IS_IN_DB(db, 'ingredient.id','%(ingredient_name)s')),
                Field('quantity'),
                Field('unit_ref', 'reference unit', requires=IS_IN_DB(db, 
'unit.id','%(unit_of_measure)s')),
                Field('is_approved', 'boolean', default=True),
                Field('drink_recipe_ingredients_so', 'integer', default=50)
                )


from a pseudo use case perspective what I want to do is:
1) back end grab 3 sets of data (one for kind, 1,2,3) kinda like:  alcohols 
= db((db.ingredient.kind_ref=='1') & (db.ingredient.for_match==True) & 
(db.ingredient.is_approved==True)).select()
2) front end display a check box that indicates that you are or are not 
including information from those three sets of information - "category 
selector"
3) display those three lists of items with check boxes next to each item in 
the list
4) let the user select the check boxes and submit
5) in the back end - use the "category selector" and the checked items in 
each category to create another query that pulls information from the 
drink_recipe_ingredients table

no data gathered is stored in the database.  more than one user can be 
executing this behavior at the same time.

Any advice on the best way to this would be great.

-- 



Reply via email to