Here CREATION :
{{extend 'layout_form.html'}}
<style type="text/css" title="currentStyle">
@import
"{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/themes/base/jquery.ui.all.css')}}";
</style>
<div class="demo">
<br/>
<br/>
<br/>
<div id="tabs">
<ul>
<li><a href="#tabs-1">{{=T('folder').capitalize()}}</a></li>
<li><a href="#tabs-2">{{=T('volume').capitalize()}}</a></li>
<li><a href="#tabs-3">{{=T('tome').capitalize()}}</a></li>
<li><a href="#tabs-4">{{=T('report').capitalize()}}</a></li>
</ul>
<div id="tabs-1">
<br/>
{{=LOAD(c='ref',f='create_fvte',args='ref_fnaregistry',extension='load',ajax=False,ajax_trap=False,target='one')}}
</div><!-- tabs-1 -->
<div id="tabs-2">
<br/>
{{=LOAD(c='ref',f='create_fvte',args='ref_vregistry',extension='load',ajax=False,ajax_trap=False,target='two')}}
</div><!-- tabs-2 -->
<div id="tabs-3">
<br/>
{{=LOAD(c='ref',f='create_fvte',args='ref_tregistry',extension='load',ajax=False,ajax_trap=False,target='three')}}
</div><!-- tabs-3 -->
<div id="tabs-4">
<br/>
{{=LOAD(c='ref',f='create_fvte',args='ref_eregistry',extension='load',ajax=False,ajax_trap=False,target='four')}}
</div><!-- tabs-4 -->
</div><!-- tabs -->
</div><!-- End demo -->
<script type="text/javascript" charset="utf-8"
src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/js/jquery-1.4.4.min.js')}}"></script>
<script type="text/javascript" charset="utf-8"
src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.core.js')}}"></script>
<script type="text/javascript" charset="utf-8"
src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.widget.js')}}"></script>
<script type="text/javascript" charset="utf-8"
src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/ui/jquery.ui.tabs.js')}}"></script>
<script>
$(function() {
var $tabs = $( "#tabs" ).tabs();
$tabs.tabs('select', {{=session.tab_pos}});
return false;
});
</script>
AND CONTROLLER :
# Tabs system for registry tables need creation() and create_fvte()
functions
@auth.requires_login()
def creation():
"""
Empty function for make it works the jQuery tabs plugin for ref_*
tables.
See the create_fvte() function docstring for more details.
creation() and create_fvte() functions work in conjonction.
"""
a = None
return dict(a=a)
@auth.requires_login()
def create_fvte():
"""
This function works in conjonction of creation() function. Both
functions
are required to make works the Tabs System for registry tables.
create_fvte() is used to allow the usage of registry tables as
component
to be loaded into creation() function. There is jQuery UI Tabs plugin
script in the view of the creation() function.
To redirect between the differents tabs programmatically we use the
tab_pos
session variable to store the index of the tabs on which the user has to
be
redirected to. We check if the create_fvte() function is call by GET
(vs POST) to determine when to initialise the pos_tab variable to zero.
The pos_tab vars is embeded into the jQuery code of the script like this
{{session.tab_pos}} in the view of creation() function.
"""
if request.env.request_method == 'GET':
session.tab_pos=0
table = request.args(0)
if auth.has_membership(auth.id_group('admin')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('technician')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('coordinator')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('technician_c')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('coordinator_c')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
else:
return dict(form=None)
if form.accepts(request.vars, session):
session.flash = T('form accepted')
if table == 'ref_fnaregistry':
session.tab_pos=1
elif table == 'ref_vregistry':
session.tab_pos=2
elif table == 'ref_tregistry':
session.tab_pos=3
elif form.errors:
response.flash = T('form has errors')
if table == 'ref_fnaregistry':
session.tab_pos=0
elif table == 'ref_vregistry':
session.tab_pos=1
elif table == 'ref_tregistry':
session.tab_pos=2
elif table == 'ref_eregistry':
session.tab_pos=3
else:
response.flash = T('please fill out the form')
return dict(form=form)
I know I am not DRY ;-)
Richard
On Mon, Jun 27, 2011 at 3:27 PM, Massimo Di Pierro <
[email protected]> wrote:
> Can you send me creation.html?
>
> On Jun 27, 2:12 pm, Richard Vézina <[email protected]>
> wrote:
> > Hello,
> >
> > I get this :
> >
> > 1.
> > 2.
> > 3.
> > 4.
> > 5.
> > 6.
> > 7.
> > 8.
> > 9.
> > 10.
> > 11.
> > 12.
> >
> > Traceback (most recent call last):
> > File "/programmation/version_197-1/web2py/gluon/restricted.py", line
> > 192, in restricted
> > exec ccode in environment
> > File
> "/version_197-1/web2py/applications/sgddms/views/ref/creation.html",
> > line 115, in <module>
> > File "/version_197-1/web2py/gluon/compileapp.py", line 142, in __call__
> > page = run_controller_in(c, f, other_environment)
> > File "/version_197-1/web2py/gluon/compileapp.py", line 418, in
> > run_controller_in
> > restricted(code, environment, filename)
> > File "/version_197-1/web2py/gluon/restricted.py", line 200, in
> restricted
> > raise RestrictedError(layer, code, '', environment)
> > RestrictedError
> >
> > With the exact same app that works under 1.96.4...
> >
> > Any idea where it's coming from??
> >
> > I got this traceback only with a new feature I just finished to prototype
> > where I use jQuery UI Tabs plugin... Could it be related to the jQuery UI
> > build I use??
> >
> > Richard
>