0001-admin-only-allow-digits-in-workflow-global-trigger-t.patch
tests/test_admin_pages.py | ||
---|---|---|
2208 | 2208 |
assert 'Timeout (not configured)' in resp.body |
2209 | 2209 | |
2210 | 2210 |
resp = resp.click(href='triggers/%s/' % Workflow.get(workflow.id).global_actions[0].triggers[0].id, index=0) |
2211 |
resp.form['timeout'] = 'foobar' |
|
2212 |
resp = resp.form.submit('submit') |
|
2213 |
assert 'wrong format' in resp.body |
|
2211 | 2214 |
resp.form['timeout'] = '3' |
2212 | 2215 |
resp = resp.form.submit('submit') |
2213 | 2216 |
wcs/qommon/form.py | ||
---|---|---|
1213 | 1213 |
'''StringWidget which checks the value entered is correct according to a regex''' |
1214 | 1214 |
regex = None |
1215 | 1215 | |
1216 |
def __init__(self, *args, **kwargs): |
|
1217 |
if 'regex' in kwargs: |
|
1218 |
self.regex = kwargs.pop('regex') |
|
1219 |
super(ValidatedStringWidget, self).__init__(*args, **kwargs) |
|
1220 | ||
1216 | 1221 |
def _parse(self, request): |
1217 | 1222 |
StringWidget._parse(self, request) |
1218 | 1223 |
if self.regex and self.value is not None: |
wcs/workflows.py | ||
---|---|---|
1039 | 1039 |
'data-dynamic-display-value': _('Latest arrival in status')} |
1040 | 1040 |
) |
1041 | 1041 | |
1042 |
form.add(StringWidget, 'timeout', title=_('Timeout'), |
|
1042 |
form.add(ValidatedStringWidget, 'timeout', title=_('Timeout'),
|
|
1043 | 1043 |
value=self.timeout, |
1044 |
regex=r'^\d*$', |
|
1044 | 1045 |
hint=_('Number of days, relative to anchor point.')) |
1045 | 1046 | |
1046 | 1047 |
return form |
1047 |
- |