Does anybody have a clue about what's going on?
Here is the list of linked tables.
linked_tables = ['user_preference', 'auth_membership',],
Smartgrid makes a link to auth_membership, but ignores user_preference.
This is the model for user_preference.
db.define_table('user_preference',
Field('user_id', db.auth_user,
requires=IS_IN_DB(
db, db.auth_user.id,
# should not need the next line because auth_user has its
own format def
# '%(first_name)s %(middle_name)s, %(last_name)s
%(generation)s',
),
label = "Person's Name",
),
Field('preference_name', length=32),
Field('preference_value', length=64),
singular = 'Preference',
plural = 'Preferences'
)
Here is the complete controller:
@auth.requires_login()
def index():
constraints = {}
fields = None
if session.auth.user.id != 1:
constraints = {usr: usr.tenant_link==session.auth.user.tenant_link}
db.auth_membership.user_id.writable = False
db.user_preference.user_id.writable = False
db.user_preference.user_id.readable = False
## indexing users
if (len(args) == 1 and args(0) == 'auth_user') or not len(args):
fields = [
db.auth_user.first_name,
db.auth_user.middle_name,
db.auth_user.last_name,
db.auth_user.generation,
]
## indexing auth_membership
elif len(args) == 3 and args[-2] == 'auth_membership.user_id':
fields = [db.auth_membership.group_id]
response.title = 'People'
response.subtitle = ''
# Here is the payoff
return dict(
form=SQLFORM.smartgrid(
usr,
linked_tables = ['user_preference', 'auth_membership',],
csv=False,
divider=XML('→'),
fields=fields,
constraints=constraints,
)
)
Thanks,
Cliff Kachinske