fixed issue 1268, better grid search options, thanks Paolo Angulo

This commit is contained in:
Massimo
2013-01-10 13:01:12 -06:00
parent 90dbf440c7
commit 8eadfe3d79
3 changed files with 30 additions and 10 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.4.1-alpha.2+timestamp.2013.01.09.16.56.34
Version 2.4.1-alpha.2+timestamp.2013.01.10.12.59.43
+4 -2
View File
@@ -375,7 +375,7 @@ class Response(Storage):
wrapped = streamer(stream, chunk_size=chunk_size)
return wrapped
def download(self, request, db, chunk_size=DEFAULT_CHUNK_SIZE, attachment=True):
def download(self, request, db, chunk_size=DEFAULT_CHUNK_SIZE, attachment=True, download_filename=None):
"""
example of usage in controller::
@@ -403,9 +403,11 @@ class Response(Storage):
raise HTTP(404)
headers = self.headers
headers['Content-Type'] = contenttype(name)
if download_filename == None:
download_filename = filename
if attachment:
headers['Content-Disposition'] = \
'attachment; filename="%s"' % filename.replace('"','\"')
'attachment; filename="%s"' % download_filename.replace('"','\"')
return self.stream(stream, chunk_size=chunk_size, request=request)
def json(self, data, default=None):
+25 -7
View File
@@ -1623,7 +1623,7 @@ class SQLFORM(FORM):
'integer': ['=', '!=', '<', '>', '<=', '>=', 'in', 'not in'],
'double': ['=', '!=', '<', '>', '<=', '>='],
'id': ['=', '!=', '<', '>', '<=', '>=', 'in', 'not in'],
'reference': ['=', '!=', '<', '>', '<=', '>=', 'in', 'not in'],
'reference': ['=', '!='],
'boolean': ['=', '!=']}
if fields[0]._db._adapter.dbengine == 'google:datastore':
search_options['string'] = ['=', '!=', '<', '>', '<=', '>=']
@@ -1641,15 +1641,33 @@ class SQLFORM(FORM):
field.label, str) and T(field.label) or field.label
selectfields.append(OPTION(label, _value=str(field)))
operators = SELECT(*[OPTION(T(option), _value=option) for option in options])
_id = "%s_%s" % (value_id,name)
if field.type == 'boolean':
value_input = SQLFORM.widgets.boolean.widget(field,field.default,_id=_id)
elif field.type == 'double':
value_input = SQLFORM.widgets.double.widget(field,field.default,_id=_id)
elif field.type == 'time':
value_input = SQLFORM.widgets.time.widget(field,field.default,_id=_id)
elif field.type == 'date':
value_input = SQLFORM.widgets.date.widget(field,field.default,_id=_id)
elif field.type == 'datetime':
value_input = SQLFORM.widgets.datetime.widget(field,field.default,_id=_id)
elif (field.type.startswith('reference ') or
field.type.startswith('list:reference ')) and \
hasattr(field.requires,'options'):
value_input = SELECT(
OPTION(T("True"), _value="T"),
OPTION(T("False"), _value="F"),
_id="%s_%s" % (value_id,name))
*[OPTION(v, _value=k)
for k,v in field.requires.options()],
**dict(_id=_id))
elif field.type == 'integer' or \
field.type.startswith('reference ') or \
field.type.startswith('list:integer') or \
field.type.startswith('list:reference '):
value_input = SQLFORM.widgets.integer.widget(field,field.default,_id=_id)
else:
value_input = INPUT(_type='text',
_id="%s_%s" % (value_id,name),
_class=field.type)
value_input = INPUT(
_type='text', _id=_id, _class=field.type)
new_button = INPUT(
_type="button", _value=T('New'), _class="btn",
_onclick="%s_build_query('new','%s')" % (prefix,field))