hi,
i have a function that must be passed with parameter, if i test to call it
from controllers it works well.
e.g. in controller
def outstanding_rent():
query = db.rent_detail.status == 'Rent'
grid = SQLFORM.grid(query, selectable = lambda ids: revert(ids) )
return locals()
def revert(ids):
for id in ids:
detail = db(db.rent_detail.id == id).select().first()
db.revert_detail.insert(rent_no = detail.rent_no,
due_date = detail.due_date,
customer = detail.customer,
dvd = detail.dvd,
quantity = detail.quantity)
redirect(URL('report', 'report_revert') )
when i try to move it to views it not work.
e.g.
*controllers/default.py*
def outstanding_rent():
query = db.rent_detail.status == 'Rent'
#grid = SQLFORM.grid(query, selectable = lambda ids: revert(ids) )
grid = SQLFORM.grid(query, selectable = lambda ids :
redirect(URL('revert_checkout', vars = dict(ids = ids) ) ) )
return locals()
def revert_checkout():
ids = request.vars.ids
return dict(ids = ids)
def revert(ids):
for id in ids:
detail = db(db.rent_detail.id == id).select().first()
db.revert_detail.insert(rent_no = detail.rent_no,
due_date = detail.due_date,
customer = detail.customer,
dvd = detail.dvd,
quantity = detail.quantity)
redirect(URL('report', 'report_revert') )
*views/default/revert_checkout.html*
<table class="table table-condensed table-hover">
<tr>
<th>{{=T('DVD')}}</th>
<th>{{=T('Quantity')}}</th>
</tr>
{{for id in ids:}}
{{detail = db(db.rent_detail.id == id).select().first()}}
<tr>
<td>{{=SPAN(detail.dvd.title)}}</td>
<td>{{=SPAN(detail.quantity)}}</td>
</tr>
{{pass}}
</table>
#test with args
{{=SPAN(A(T('Process 1'), _href=URL('revert', args = ids) ) ) }}
#test with vars
{{=SPAN(A(T('Process 2'), _href=URL('revert', vars = dict(ids = ids) ) ) )
}}
#test call like on controler
{{=SPAN(A(T('Process 3'), _href=URL('revert(ids)' ) ) ) }}
is it possible to call function with parameter from views?
thanks and best regards,
stifan
--
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/groups/opt_out.