I have a table like this:
db.define_table('visit',
Field('project_id', 'integer', 'references projects'),
Field('arrival_date','date'),
Field('departure_date','date'),
Field('number_of_visitors','integer'),
Field('purpose','text'),
Field('proposer_id', 'integer', 'references auth_user'),
Field('approval_status', 'string',
requires=IS_IN_SET(['Yes','No','Pending']),
default='Pending')
I'm using SQLFORM.grid to see a list of Pending visits and allow admin
users to click through to the SQLFORM for a given visit to set the approval
status. This all works fine, except that I'd like the SQLFORM for a visit
to substitute in the project name and proposer name from the two referenced
tables, rather than just giving the ID numbers.
I've tried playing around with passing in a joined query and using the
'left=' argument, but as far as I can tell you can only get the fields from
a single table (although you can switch _which_ table using 'field_id=').
My controller currently looks like this - I'm using editargs to control
which field appear in the SQLFORM and I have tried including fields from
joined tables in here, but with no success.
@auth.requires_membership('admin')
def visit_admin_old():
# don't want the admin to change any of this about a visit
db.visit.project_id.writable = False
db.visit.proposer_id.writable = False
db.visit.arrival_date.writable = False
db.visit.departure_date.writable = False
db.visit.number_of_visitors.writable = False
db.visit.purpose.writable = False
# get a query of pending requests with user_id
form = SQLFORM.grid(query=(db.visit.visit_status == 'Pending'), csv=
False,
fields=[db.visit.arrival_date,
db.visit.departure_date,
db.visit.number_of_visitors,
db.visit.purpose],
maxtextlength=250,
deletable=False,
editable=True,
create=False,
details=False,
editargs = {'fields': ['project_id','proposer_id',
'arrival_date',
'departure_date',
'number_of_visitors',
'purpose',
'visit_status',
'visit_decision_notes'],
'showid': False})
return dict(form=form)
Thanks in advance,
David
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.