| 78 | | |
| 79 | | List output can be made more functional by adding this to your table definitions in models/db.py: |
| 80 | | {{{db.table.represent=lambda table: A(table.display_field,_href=t2.action('display_table',table.id))}}} |
| | 78 | List output can be made more functional by this .represent 'widget': |
| | 79 | {{{ |
| | 80 | def shn_list_item(table,resource,action,display='table.name',extra=None): |
| | 81 | if extra: |
| | 82 | items=DIV(TR(TD(A(eval(display),_href=t2.action(resource,[action,table.id]))),TD(eval(extra)))) |
| | 83 | else: |
| | 84 | items=DIV(A(eval(display),_href=t2.action(resource,[action,table.id]))) |
| | 85 | return DIV(*items) |
| | 86 | }}} |
| | 87 | You can use it in {{{models/module.py}}} like: |
| | 88 | {{{ |
| | 89 | db.or_organisation.represent=lambda table:shn_list_item(table,resource='organisation',action='display') |
| | 90 | db.person.represent=lambda table:shn_list_item(table,resource='person',action='display',display='table.full_name') |
| | 91 | db.gis_projection.represent=lambda table:shn_list_item(table,resource='projection',action='display',extra='table.epsg') |
| | 92 | }}} |