Thanks , as always...

2016-10-01 19:05 GMT+01:00 Anthony <abasta...@gmail.com>:

> If you want to do it using the /appadmin/manage functionality, you can add
> something like the following to a model file:
>
> def make_clone_link(r):
>     tablename = request.args(2)
>     index = db.tables.index(tablename)
>     return URL('appadmin', 'manage.load', args=['db', index, tablename,
> 'new', tablename],
>                vars=dict(clone_id=r.id), user_signature=True, hash_vars=
> False)
>
> auth.settings.manager_actions = dict(
>     db=dict(role='admin', tables=db.tables,
>             smartgrid_args=dict(
>                 DEFAULT=dict(links=[lambda r: A(SPAN('Clone', 
> _class='buttontext
> button'),
>                                                 cid=request.cid, _href=
> make_clone_link(r),
>                                                 _class='button btn
> btn-default')]))
>     )
> )
>
> if request.controller == 'appadmin' and 'clone_id' in request.get_vars:
>     table = db[request.args(2)]
>     record = table[int(request.vars.clone_id)]
>     for field in table:
>         if field.type != 'id':
>             field.default = record[field.name]
>
> Then make sure you have the role "admin" and go to /appadmin/manage/db.
> You'll be able to browse all the database tables via SQLFORM.smartgrid, and
> each record will have a "Clone" button.
>
> Note, the /appadmin/manage UI depends somewhat on Bootstrap, so if you're
> not using Bootstrap, you may have to make sure it is loaded at least for
> /appadmin/manage requests.
>
> Anthony
>
> --
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to