Changes between Version 4 and Version 5 of JoinedResourceController


Ignore:
Timestamp:
09/20/09 18:36:19 (15 years ago)
Author:
Fran Boon
Comment:

Options: s3.pdf, s3.xls & s3.filter

Legend:

Unmodified
Added
Removed
Modified
  • JoinedResourceController

    v4 v5  
    5959{{{
    6060def person():
    61     crud.settings.delete_onvalidation=shn_pentity_ondelete
     61    crud.settings.delete_onvalidation = shn_pentity_ondelete
    6262    return shn_rest_controller(module, 'person', main='first_name', extra='last_name',
    6363        pheader=shn_pr_pheader,
     
    7979  * '''NOTE:''' Callbacks from CRUD settings (like in the example above) as well as onvalidation and onaccept callbacks are only invoked at requests on the main resource, but not at joined requests.
    8080
     81There are some options which can be set before invoking the REST controller:
     82{{{
     83def kit():
     84    "RESTlike CRUD controller"
     85    s3.pdf = URL(r=request, f='kit_export_pdf')
     86    s3.xls = URL(r=request, f='kit_export_xls')
     87    if len(request.args) == 2:
     88        crud.settings.update_next = URL(r=request, f='kit_item', args=request.args[1])
     89    return shn_rest_controller(module, 'kit', main='code', onaccept=lambda form: kit_total(form))
     90}}}
     91
     92The {{{s3.pdf}}} & {{{s3.xls}}} provide the {{{view/formats.html}}} with an alternate URL to provide a customised version of the PDF/XLS output available when clicking on the icon (s3.rss is also available).
     93
     94{{{
     95def report_overdue():
     96    "Report on Overdue Invoices - those unpaid 30 days after receipt"
     97    response.title = T('Overdue Invoices')
     98    overdue = datetime.date.today() - timedelta(days=30)
     99    s3.filter = (db.fin_invoice.date_out==None) & (db.fin_invoice.date_in < overdue)
     100    s3.crud_strings.fin_invoice.title_list = response.title
     101    s3.crud_strings.fin_invoice.msg_list_empty = T('No Invoices currently overdue')
     102    return shn_rest_controller(module, 'invoice', deletable=False, listadd=False)
     103}}}
     104
     105The {{{s3.filter}}} provides a filter which is used in the list view to show the desired subset of records (note that the s3.crud_strings can also be customised). When done in the Controller like this, they are good for just this request)
    81106== Argument Lists ==
    82107