Merge pull request #872 from BuhtigithuB/pep8-sqlhtml-py
Improve PEP8 gluon/sqlhtml.py
This commit is contained in:
+32
-33
@@ -903,7 +903,7 @@ def formstyle_bootstrap3_inline_factory(col_label_size=3):
|
|||||||
label['_for'] = None
|
label['_for'] = None
|
||||||
label.insert(0, controls)
|
label.insert(0, controls)
|
||||||
_controls = DIV(DIV(label, _help, _class="checkbox"),
|
_controls = DIV(DIV(label, _help, _class="checkbox"),
|
||||||
_class="%s %s" % (offset_class, col_class))
|
_class="%s %s" % (offset_class, col_class))
|
||||||
label = ''
|
label = ''
|
||||||
elif isinstance(controls, (SELECT, TEXTAREA)):
|
elif isinstance(controls, (SELECT, TEXTAREA)):
|
||||||
controls.add_class('form-control')
|
controls.add_class('form-control')
|
||||||
@@ -1590,7 +1590,7 @@ class SQLFORM(FORM):
|
|||||||
(cStringIO.StringIO(f), 'file.txt')
|
(cStringIO.StringIO(f), 'file.txt')
|
||||||
else:
|
else:
|
||||||
# this should never happen, why does it happen?
|
# this should never happen, why does it happen?
|
||||||
# print 'f=',repr(f)
|
# print 'f=', repr(f)
|
||||||
continue
|
continue
|
||||||
newfilename = field.store(source_file, original_filename,
|
newfilename = field.store(source_file, original_filename,
|
||||||
field.uploadfolder)
|
field.uploadfolder)
|
||||||
@@ -1827,16 +1827,16 @@ class SQLFORM(FORM):
|
|||||||
else:
|
else:
|
||||||
field_type = field.type
|
field_type = field.type
|
||||||
|
|
||||||
operators = SELECT(*[OPTION(T(option), _value=option) for option in options],_class='form-control')
|
operators = SELECT(*[OPTION(T(option), _value=option) for option in options], _class='form-control')
|
||||||
_id = "%s_%s" % (value_id, name)
|
_id = "%s_%s" % (value_id, name)
|
||||||
if field_type in ['boolean', 'double', 'time', 'integer']:
|
if field_type in ['boolean', 'double', 'time', 'integer']:
|
||||||
value_input = SQLFORM.widgets[field_type].widget(field, field.default, _id=_id,_class='form-control')
|
value_input = SQLFORM.widgets[field_type].widget(field, field.default, _id=_id, _class='form-control')
|
||||||
elif field_type == 'date':
|
elif field_type == 'date':
|
||||||
iso_format = {'_data-w2p_date_format' : '%Y-%m-%d'}
|
iso_format = {'_data-w2p_date_format' : '%Y-%m-%d'}
|
||||||
value_input = SQLFORM.widgets.date.widget(field, field.default, _id=_id,_class='form-control', **iso_format)
|
value_input = SQLFORM.widgets.date.widget(field, field.default, _id=_id, _class='form-control', **iso_format)
|
||||||
elif field_type == 'datetime':
|
elif field_type == 'datetime':
|
||||||
iso_format = {'_data-w2p_datetime_format' : '%Y-%m-%d %H:%M:%S'}
|
iso_format = {'_data-w2p_datetime_format' : '%Y-%m-%d %H:%M:%S'}
|
||||||
value_input = SQLFORM.widgets.datetime.widget(field, field.default, _id=_id,_class='form-control', **iso_format)
|
value_input = SQLFORM.widgets.datetime.widget(field, field.default, _id=_id, _class='form-control', **iso_format)
|
||||||
elif (field_type.startswith('reference ') or
|
elif (field_type.startswith('reference ') or
|
||||||
field_type.startswith('list:reference ')) and \
|
field_type.startswith('list:reference ')) and \
|
||||||
hasattr(field.requires, 'options'):
|
hasattr(field.requires, 'options'):
|
||||||
@@ -1848,7 +1848,7 @@ class SQLFORM(FORM):
|
|||||||
elif field_type.startswith('reference ') or \
|
elif field_type.startswith('reference ') or \
|
||||||
field_type.startswith('list:integer') or \
|
field_type.startswith('list:integer') or \
|
||||||
field_type.startswith('list:reference '):
|
field_type.startswith('list:reference '):
|
||||||
value_input = SQLFORM.widgets.integer.widget(field, field.default, _id=_id,_class='form-control')
|
value_input = SQLFORM.widgets.integer.widget(field, field.default, _id=_id, _class='form-control')
|
||||||
else:
|
else:
|
||||||
value_input = INPUT(
|
value_input = INPUT(
|
||||||
_type='text', _id=_id,
|
_type='text', _id=_id,
|
||||||
@@ -2041,7 +2041,7 @@ class SQLFORM(FORM):
|
|||||||
c = 'count(*)'
|
c = 'count(*)'
|
||||||
nrows = dbset.select(c, left=left, cacheable=True, cache=cache_count).first()[c]
|
nrows = dbset.select(c, left=left, cacheable=True, cache=cache_count).first()[c]
|
||||||
elif dbset._db._adapter.dbengine == 'google:datastore':
|
elif dbset._db._adapter.dbengine == 'google:datastore':
|
||||||
#if we don't set a limit, this can timeout for a large table
|
# if we don't set a limit, this can timeout for a large table
|
||||||
nrows = dbset.db._adapter.count(dbset.query, limit=1000)
|
nrows = dbset.db._adapter.count(dbset.query, limit=1000)
|
||||||
else:
|
else:
|
||||||
nrows = dbset.count(cache=cache_count)
|
nrows = dbset.count(cache=cache_count)
|
||||||
@@ -2292,20 +2292,20 @@ class SQLFORM(FORM):
|
|||||||
ondelete(table, request.args[-1])
|
ondelete(table, request.args[-1])
|
||||||
record.delete_record()
|
record.delete_record()
|
||||||
if request.ajax:
|
if request.ajax:
|
||||||
#this means javascript is enabled, so we don't need to do
|
# this means javascript is enabled, so we don't need to do
|
||||||
#a redirect
|
# a redirect
|
||||||
if not client_side_delete:
|
if not client_side_delete:
|
||||||
#if it's an ajax request and we don't need to reload the
|
# if it's an ajax request and we don't need to reload the
|
||||||
#entire page, let's just inform that there have been no
|
# entire page, let's just inform that there have been no
|
||||||
#exceptions and don't regenerate the grid
|
# exceptions and don't regenerate the grid
|
||||||
raise HTTP(200)
|
raise HTTP(200)
|
||||||
else:
|
else:
|
||||||
#if it's requested that the grid gets reloaded on delete
|
# if it's requested that the grid gets reloaded on delete
|
||||||
#on ajax, the redirect should be on the original location
|
# on ajax, the redirect should be on the original location
|
||||||
newloc = request.env.http_web2py_component_location
|
newloc = request.env.http_web2py_component_location
|
||||||
redirect(newloc, client_side=client_side_delete)
|
redirect(newloc, client_side=client_side_delete)
|
||||||
else:
|
else:
|
||||||
#we need to do a redirect because javascript is not enabled
|
# we need to do a redirect because javascript is not enabled
|
||||||
redirect(referrer, client_side=client_side_delete)
|
redirect(referrer, client_side=client_side_delete)
|
||||||
|
|
||||||
exportManager = dict(
|
exportManager = dict(
|
||||||
@@ -3082,23 +3082,22 @@ class SQLTABLE(TABLE):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(self,
|
||||||
self,
|
sqlrows,
|
||||||
sqlrows,
|
linkto=None,
|
||||||
linkto=None,
|
upload=None,
|
||||||
upload=None,
|
orderby=None,
|
||||||
orderby=None,
|
headers={},
|
||||||
headers={},
|
truncate=16,
|
||||||
truncate=16,
|
columns=None,
|
||||||
columns=None,
|
th_link='',
|
||||||
th_link='',
|
extracolumns=None,
|
||||||
extracolumns=None,
|
selectid=None,
|
||||||
selectid=None,
|
renderstyle=False,
|
||||||
renderstyle=False,
|
cid=None,
|
||||||
cid=None,
|
colgroup=False,
|
||||||
colgroup=False,
|
**attributes
|
||||||
**attributes
|
):
|
||||||
):
|
|
||||||
|
|
||||||
TABLE.__init__(self, **attributes)
|
TABLE.__init__(self, **attributes)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user