Merge pull request #467 from ilvalle/fix_show_if
fix show_if with belongs
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user