Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# vars=dict(keywords=request.vars.keywords or ''))))
#================================================================
options =[]
for k,v in sorted(exportManager.items()):
if hasattr(v, "__getitem__"):
label = v[1]
else:
label = k
options.append(OPTION(T(label),_value=k))
##FIXME ?
mysignature = url(args=['export']).split('?', 1)
mysignature = psq(mysignature[-1]).get('_signature', [None])[-1]
f = FORM(BUTTON(SPAN(_class=ui.get('buttonexport')),
"Export", _type="submit", _class=ui.get('button')),
SELECT(options, _name="export_type"),
INPUT(_type="hidden", _name="order",
_value=request.vars.order),
INPUT(_type="hidden", _name="_signature",
_value=mysignature),
INPUT(_type="hidden", _name="keywords",
_value=request.vars.keywords or ''),
_method="GET", _action=url(args=['export']))
search_actions.append(f)
#================================================================
console.append(search_actions)
order = request.vars.order or ''
if sortable:
if order and not order=='None':
# vars=dict(keywords=request.vars.keywords or ''))))
#================================================================
options =[]
for k,v in sorted(exportManager.items()):
if hasattr(v, "__getitem__"):
label = v[1]
else:
label = k
options.append(OPTION(T(label),_value=k))
##FIXME ?
mysignature = url(args=['export']).split('?', 1)
mysignature = psq(mysignature[-1]).get('_signature', [None])[-1]
f = FORM(BUTTON(SPAN(_class=ui.get('buttonexport')),
"Export", _type="submit", _class=ui.get('button')),
SELECT(options, _name="export_type"),
INPUT(_type="hidden", _name="order",
_value=request.vars.order),
INPUT(_type="hidden", _name="_signature",
_value=mysignature),
INPUT(_type="hidden", _name="keywords",
_value=request.vars.keywords or ''),
_method="GET", _action=url(args=['export']))
search_actions.append(f)
#================================================================
console.append(search_actions)
order = request.vars.order or ''
if sortable:
if order and not order=='None':
'boolean':['=','!=']}
if fields[0]._db._adapter.dbengine=='google:datastore':
search_options['string'] = ['=','!=','<','>','<=','>=']
search_options['text'] = ['=','!=','<','>','<=','>=']
criteria = []
selectfields = []
for field in fields:
name = str(field).replace('.','-')
criterion = []
options = search_options.get(field.type,None)
if options:
label = isinstance(field.label,str) and T(field.label) or field.label
selectfields.append((str(field),label))
operators = SELECT(*[T(option) for option in options])
if field.type=='boolean':
value_input = SELECT(
OPTION(T("True"),_value="T"),OPTION(T("False"),_value="F"),
_id="w2p_value_"+name)
else:
value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
new_button = INPUT(_type="button", _value=T('New'),
_onclick="w2p_build_query('new','"+str(field)+"')")
and_button = INPUT(_type="button", _value=T('And'),
_onclick="w2p_build_query('and','"+str(field)+"')")
or_button = INPUT(_type="button", _value=T('Or'),
_onclick="w2p_build_query('or','"+str(field)+"')")
criterion.extend([operators,value_input,new_button,and_button,or_button])
criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
_class='w2p_query_row hidden'))
criteria.insert(0,SELECT(
_id="w2p_query_fields",
value_input = SELECT(
OPTION(T("True"),_value="T"),OPTION(T("False"),_value="F"),
_id="w2p_value_"+name)
else:
value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
new_button = INPUT(_type="button", _value=T('New'),
_onclick="w2p_build_query('new','"+str(field)+"')")
and_button = INPUT(_type="button", _value=T('And'),
_onclick="w2p_build_query('and','"+str(field)+"')")
or_button = INPUT(_type="button", _value=T('Or'),
_onclick="w2p_build_query('or','"+str(field)+"')")
criterion.extend([operators,value_input,new_button,and_button,or_button])
criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
_class='w2p_query_row hidden'))
criteria.insert(0,SELECT(
_id="w2p_query_fields",
_onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();",
*[OPTION(label, _value=fname) for fname,label in selectfields]))
fadd = SCRIPT("""
jQuery('#w2p_query_panel input,#w2p_query_panel select').css(
'width','auto').css('float','left');
jQuery(function(){web2py_ajax_fields('#w2p_query_panel');});
function w2p_build_query(aggregator,a){
var b=a.replace('.','-');
var option = jQuery('#w2p_field_'+b+' select').val();
var value = jQuery('#w2p_value_'+b).val().replace('"','\\\\"');
var s=a+' '+option+' "'+value+'"';
var k=jQuery('#web2py_keywords');
var v=k.val();
if(aggregator=='new') k.val(s); else k.val((v?(v+' '+ aggregator +' '):'')+s);
jQuery('#w2p_query_panel').slideUp();
def callback(self):
if self.keyword in self.request.vars:
field = self.fields[0]
rows = self.db(field.like(self.request.vars[self.keyword]+'%'))\
.select(orderby=self.orderby,limitby=self.limitby,*self.fields)
if rows:
if self.is_reference:
id_field = self.fields[1]
raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
_size=len(rows),_multiple=(len(rows)==1),
*[OPTION(s[field.name],_value=s[id_field.name],
_selected=(k==0)) \
for k,s in enumerate(rows)]).xml())
else:
raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
_size=len(rows),_multiple=(len(rows)==1),
*[OPTION(s[field.name],
_selected=(k==0)) \
for k,s in enumerate(rows)]).xml())
else:
raise HTTP(200,'')
def __call__(self,field,value,**attributes):
'integer':['=','!=','<','>','<=','>='],
'double':['=','!=','<','>','<=','>='],
'boolean':['=','!=']}
if fields[0]._db._adapter.dbengine=='google:datastore':
search_options['string'] = ['=','!=','<','>','<=','>=']
search_options['text'] = ['=','!=','<','>','<=','>=']
criteria = []
selectfields = []
for field in fields:
name = str(field).replace('.','-')
criterion = []
options = search_options.get(field.type,None)
if options:
label = isinstance(field.label,str) and T(field.label) or field.label
selectfields.append((str(field),label))
operators = SELECT(*[T(option) for option in options])
if field.type=='boolean':
value_input = SELECT(
OPTION(T("True"),_value="T"),OPTION(T("False"),_value="F"),
_id="w2p_value_"+name)
else:
value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
new_button = INPUT(_type="button", _value=T('New'),
_onclick="w2p_build_query('new','"+str(field)+"')")
and_button = INPUT(_type="button", _value=T('And'),
_onclick="w2p_build_query('and','"+str(field)+"')")
or_button = INPUT(_type="button", _value=T('Or'),
_onclick="w2p_build_query('or','"+str(field)+"')")
criterion.extend([operators,value_input,new_button,and_button,or_button])
criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
_class='w2p_query_row hidden'))
.select(orderby=self.orderby,limitby=self.limitby,
distinct=self.distinct,*self.fields)
if rows:
if self.is_reference:
id_field = self.fields[1]
if self.help_fields:
options = [OPTION(self.help_string % dict([(h.name,s[h.name]) for h in self.fields[:1]+self.help_fields]),
_value=s[id_field.name], _selected=(k==0)) for k,s in enumerate(rows)]
else:
options = [OPTION(s[field.name],_value=s[id_field.name],
_selected=(k==0)) for k,s in enumerate(rows)]
raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
_size=len(rows),_multiple=(len(rows)==1),
*options).xml())
else:
raise HTTP(200,SELECT(_id=self.keyword,_class='autocomplete',
_size=len(rows),_multiple=(len(rows)==1),
*[OPTION(s[field.name],
_selected=(k==0)) \
for k,s in enumerate(rows)]).xml())
else:
raise HTTP(200,'')
'integer':['=','!=','<','>','<=','>='],
'double':['=','!=','<','>','<=','>='],
'boolean':['=','!=']}
if fields[0]._db._adapter.dbengine=='google:datastore':
search_options['string'] = ['=','!=','<','>','<=','>=']
search_options['text'] = ['=','!=','<','>','<=','>=']
criteria = []
selectfields = []
for field in fields:
name = str(field).replace('.','-')
criterion = []
options = search_options.get(field.type,None)
if options:
label = isinstance(field.label,str) and T(field.label) or field.label
selectfields.append((str(field),label))
operators = SELECT(*[T(option) for option in options])
if field.type=='boolean':
value_input = SELECT(
OPTION(T("True"),_value="T"),OPTION(T("False"),_value="F"),
_id="w2p_value_"+name)
else:
value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
new_button = INPUT(_type="button", _value=T('New'),
_onclick="w2p_build_query('new','"+str(field)+"')")
and_button = INPUT(_type="button", _value=T('And'),
_onclick="w2p_build_query('and','"+str(field)+"')")
or_button = INPUT(_type="button", _value=T('Or'),
_onclick="w2p_build_query('or','"+str(field)+"')")
criterion.extend([operators,value_input,new_button,and_button,or_button])
criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
_class='w2p_query_row hidden'))
value_input = SELECT(
OPTION(T("True"),_value="T"),OPTION(T("False"),_value="F"),
_id="w2p_value_"+name)
else:
value_input = INPUT(_type='text',_id="w2p_value_"+name,_class=field.type)
new_button = INPUT(_type="button", _value=T('New'),
_onclick="w2p_build_query('new','"+str(field)+"')")
and_button = INPUT(_type="button", _value=T('And'),
_onclick="w2p_build_query('and','"+str(field)+"')")
or_button = INPUT(_type="button", _value=T('Or'),
_onclick="w2p_build_query('or','"+str(field)+"')")
criterion.extend([operators,value_input,new_button,and_button,or_button])
criteria.append(DIV(criterion, _id='w2p_field_%s' % name,
_class='w2p_query_row hidden'))
criteria.insert(0,SELECT(
_id="w2p_query_fields",
_onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();",
*[OPTION(label, _value=fname) for fname,label in selectfields]))
fadd = SCRIPT("""
jQuery('#w2p_query_panel input,#w2p_query_panel select').css(
'width','auto').css('float','left');
jQuery(function(){web2py_ajax_fields('#w2p_query_panel');});
function w2p_build_query(aggregator,a){
var b=a.replace('.','-');
var option = jQuery('#w2p_field_'+b+' select').val();
var value = jQuery('#w2p_value_'+b).val().replace('"','\\\\"');
var s=a+' '+option+' "'+value+'"';
var k=jQuery('#web2py_keywords');
var v=k.val();
if(aggregator=='new') k.val(s); else k.val((v?(v+' '+ aggregator +' '):'')+s);
jQuery('#w2p_query_panel').slideUp();