Merge pull request #467 from ilvalle/fix_show_if

fix show_if with belongs
This commit is contained in:
mdipierro
2014-07-10 02:06:40 -05:00
2 changed files with 6 additions and 3 deletions

View File

@@ -7390,7 +7390,7 @@ def sqlhtml_validators(field):
def repr_list(values, row=None): return', '.join(str(v) for v in (values or []))
field.represent = field.represent or repr_list
if field.unique:
requires.insert(0, validators.IS_NOT_IN_DB(db, field))
requires.append(validators.IS_NOT_IN_DB(db, field))
sff = ['in', 'do', 'da', 'ti', 'de', 'bo']
if field.notnull and not field_type[:2] in sff:
requires.insert(0, validators.IS_NOT_EMPTY())

View File

@@ -94,8 +94,11 @@ def show_if(cond):
return base, "[value!='%s']" % cond.second
if cond.op.__name__ == 'CONTAINS':
return base, "[value~='%s']" % cond.second
if cond.op.__name__ == 'BELONGS' and isinstance(cond.second, (list, tuple)):
return base, ','.join("[value='%s']" % (v) for v in cond.second)
if cond.op.__name__ == 'BELONGS':
if isinstance(cond.second, set):
cond.second = list(cond.second)
if isinstance(cond.second, (list, tuple)):
return base, ','.join("[value='%s']" % (v) for v in cond.second)
raise RuntimeError("Not Implemented Error")