Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#================================================================
console.append(search_actions)
order = request.vars.order or ''
if sortable:
if order and not order=='None':
tablename,fieldname = order.split('~')[-1].split('.',1)
sort_field = db[tablename][fieldname]
exception = sort_field.type in ('date','datetime','time')
if exception:
orderby = (order[:1]=='~' and sort_field) or ~sort_field
else:
orderby = (order[:1]=='~' and ~sort_field) or sort_field
head = TR(_class=ui.get('header'))
if selectable:
head.append(TH(_class=ui.get('default')))
for field in fields:
if columns and not str(field) in columns: continue
if not field.readable: continue
key = str(field)
header = headers.get(str(field),
hasattr(field,'label') and field.label or key)
if sortable:
if key == order:
key, marker = '~'+order, sorter_icons[0]
elif key == order[1:]:
marker = sorter_icons[1]
else:
marker = ''
header = A(header,marker,_href=url(vars=dict(
#================================================================
console.append(search_actions)
order = request.vars.order or ''
if sortable:
if order and not order=='None':
tablename,fieldname = order.split('~')[-1].split('.',1)
sort_field = db[tablename][fieldname]
exception = sort_field.type in ('date','datetime','time')
if exception:
orderby = (order[:1]=='~' and sort_field) or ~sort_field
else:
orderby = (order[:1]=='~' and ~sort_field) or sort_field
head = TR(_class=ui.get('header'))
if selectable:
head.append(TH(_class=ui.get('default')))
for field in fields:
if columns and not str(field) in columns: continue
if not field.readable: continue
key = str(field)
header = headers.get(str(field),
hasattr(field,'label') and field.label or key)
if sortable:
if key == order:
key, marker = '~'+order, sorter_icons[0]
elif key == order[1:]:
marker = sorter_icons[1]
else:
marker = ''
header = A(header,marker,_href=url(vars=dict(
def createform(self, xfields):
if self.formstyle == 'table3cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw')
table.append(TR(TD(a,_class='w2p_fl'),
td_b,
TD(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'table2cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw',_colspan="2")
table.append(TR(TD(a,_class='w2p_fl'),
TD(c,_class='w2p_fc'),_id=id
+'1',_class='even'))
table.append(TR(td_b,_id=id+'2',_class='odd'))
elif self.formstyle == 'divs':
table = TAG['']()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(DIV(DIV(a,_class='w2p_fl'),
div_b,
DIV(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'ul':
table = UL()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(LI(DIV(a,_class='w2p_fl'),
div_b,
DIV(c,_class='w2p_fc'),_id=id))
elif type(self.formstyle) == type(lambda:None):
table = TABLE()
def createform(self, xfields):
if self.formstyle == 'table3cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw')
table.append(TR(TD(a,_class='w2p_fl'),
td_b,
TD(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'table2cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw',_colspan="2")
table.append(TR(TD(a,_class='w2p_fl'),
TD(c,_class='w2p_fc'),_id=id
+'1',_class='even'))
table.append(TR(td_b,_id=id+'2',_class='odd'))
elif self.formstyle == 'divs':
table = TAG['']()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(DIV(DIV(a,_class='w2p_fl'),
div_b,
DIV(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'ul':
table = UL()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(LI(DIV(a,_class='w2p_fl'),
div_b,
DIV(c,_class='w2p_fc'),_id=id))
elif callable(self.formstyle):
table = TABLE()
def toolbar(self):
from html import DIV, SCRIPT, BEAUTIFY, TAG, URL
BUTTON = TAG.button
admin = URL("admin","default","design",
args=current.request.application)
from gluon.dal import thread
if hasattr(thread,'instances'):
dbstats = [TABLE(*[TR(PRE(row[0]),'%.2fms' % (row[1]*1000)) \
for row in i.db._timings]) \
for i in thread.instances]
else:
dbstats = [] # if no db or on GAE
u = web2py_uuid()
return DIV(
BUTTON('design',_onclick="document.location='%s'" % admin),
BUTTON('request',_onclick="jQuery('#request-%s').slideToggle()"%u),
DIV(BEAUTIFY(current.request),_class="hidden",_id="request-%s"%u),
BUTTON('session',_onclick="jQuery('#session-%s').slideToggle()"%u),
DIV(BEAUTIFY(current.session),_class="hidden",_id="session-%s"%u),
BUTTON('response',_onclick="jQuery('#response-%s').slideToggle()"%u),
DIV(BEAUTIFY(current.response),_class="hidden",_id="response-%s"%u),
BUTTON('db stats',_onclick="jQuery('#db-stats-%s').slideToggle()"%u),
DIV(BEAUTIFY(dbstats),_class="hidden",_id="db-stats-%s"%u),
SCRIPT("jQuery('.hidden').hide()")
def createform(self, xfields):
if self.formstyle == 'table3cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw')
table.append(TR(TD(a,_class='w2p_fl'),
td_b,
TD(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'table2cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw',_colspan="2")
table.append(TR(TD(a,_class='w2p_fl'),
TD(c,_class='w2p_fc'),_id=id
+'1',_class='even'))
table.append(TR(td_b,_id=id+'2',_class='odd'))
elif self.formstyle == 'divs':
table = TAG['']()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(DIV(DIV(a,_class='w2p_fl'),
div_b,
def __str__(self):
s = html.TR(
html.TD(
self._syntax(self.name + " = " + self.value)
),
html.TD(textish.Textish(self.doc)),
)
return unicode(s)
def createform(self, xfields):
if self.formstyle == 'table3cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw')
table.append(TR(TD(a,_class='w2p_fl'),
td_b,
TD(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'table2cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw',_colspan="2")
table.append(TR(TD(a,_class='w2p_fl'),
TD(c,_class='w2p_fc'),_id=id
+'1',_class='even'))
table.append(TR(td_b,_id=id+'2',_class='odd'))
elif self.formstyle == 'divs':
table = TAG['']()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(DIV(DIV(a,_class='w2p_fl'),
div_b,
DIV(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'ul':
table = UL()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(LI(DIV(a,_class='w2p_fl'),
div_b,
DIV(c,_class='w2p_fc'),_id=id))
elif callable(self.formstyle):
table = TABLE()
elif orderby:
row.append(TH(A(headers.get(c, c),
_href=th_link+'?orderby=' + c)))
else:
row.append(TH(headers.get(c, c)))
if extracolumns:#new implement dict
for c in extracolumns:
attrcol = dict()
if c['width']!="":
attrcol.update(_width=c['width'])
if c['class']!="":
attrcol.update(_class=c['class'])
row.append(TH(c['label'],**attrcol))
components.append(THEAD(TR(*row)))
tbody = []
for (rc, record) in enumerate(sqlrows):
row = []
if rc % 2 == 0:
_class = 'even'
else:
_class = 'odd'
if not selectid is None: #new implement
if record[self.id_field_name]==selectid:
_class += ' rowselected'
for colname in columns:
if not table_field.match(colname):
def createform(self, xfields):
if self.formstyle == 'table3cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw')
table.append(TR(TD(a,_class='w2p_fl'),
td_b,
TD(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'table2cols':
table = TABLE()
for id,a,b,c in xfields:
td_b = self.field_parent[id] = TD(b,_class='w2p_fw',_colspan="2")
table.append(TR(TD(a,_class='w2p_fl'),
TD(c,_class='w2p_fc'),_id=id
+'1',_class='even'))
table.append(TR(td_b,_id=id+'2',_class='odd'))
elif self.formstyle == 'divs':
table = TAG['']()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(DIV(DIV(a,_class='w2p_fl'),
div_b,
DIV(c,_class='w2p_fc'),_id=id))
elif self.formstyle == 'ul':
table = UL()
for id,a,b,c in xfields:
div_b = self.field_parent[id] = DIV(b,_class='w2p_fw')
table.append(LI(DIV(a,_class='w2p_fl'),
div_b,