fields: allow basic substitutions variables on django validation (#67734)
This commit is contained in:
parent
ac6d458edd
commit
357cb20d7d
|
@ -1159,6 +1159,13 @@ def test_wcsextrastringwidget_django_validation():
|
|||
assert widget.has_error()
|
||||
assert widget.error == 'Foo Bar Custom Error'
|
||||
|
||||
pub.substitutions.feed(pub)
|
||||
fakefield.validation = {'type': 'django', 'value': 'value|decimal == today.year'}
|
||||
widget = WcsExtraStringWidget('test', value='foo', required=False)
|
||||
widget.field = fakefield
|
||||
mock_form_submission(req, widget, {'test': str(datetime.date.today().year)})
|
||||
assert not widget.has_error()
|
||||
|
||||
|
||||
def test_widgetdict_widget():
|
||||
widget = WidgetDict('test', value={'a': None, 'b': None, 'c': None})
|
||||
|
|
|
@ -1116,7 +1116,9 @@ class ValidationCondition(Condition):
|
|||
self.evaluated_value = value
|
||||
|
||||
def get_data(self):
|
||||
return {'value': self.evaluated_value}
|
||||
data = get_publisher().get_substitution_variables()
|
||||
data['value'] = self.evaluated_value
|
||||
return data
|
||||
|
||||
|
||||
class ValidationWidget(CompositeWidget):
|
||||
|
|
Loading…
Reference in New Issue