Projet

Général

Profil

0002-misc-display-errors-associated-to-post-condition-fie.patch

Frédéric Péters, 23 janvier 2022 10:08

Télécharger (2,66 ko)

Voir les différences:

Subject: [PATCH 2/2] misc: display errors associated to post condition fields
 (#31247)

 tests/admin_pages/test_form.py       | 7 +++++++
 wcs/qommon/form.py                   | 1 +
 wcs/qommon/static/css/dc2/admin.scss | 8 ++++++--
 3 files changed, 14 insertions(+), 2 deletions(-)
tests/admin_pages/test_form.py
2193 2193
        {'condition': {'type': 'django', 'value': 'foo3'}, 'error_message': 'bar2'},
2194 2194
    ]
2195 2195

  
2196
    # check error in expression
2197
    resp = resp.click('Edit', href='1/')
2198
    resp.form['post_conditions$element1$condition$type'] = 'django'
2199
    resp.form['post_conditions$element1$condition$value_django'] = 'foo3 >'
2200
    resp = resp.form.submit('submit')
2201
    assert 'syntax error: Unexpected end of expression in if tag.' in resp.text
2202

  
2196 2203

  
2197 2204
def test_form_edit_comment_field(pub):
2198 2205
    create_superuser(pub)
wcs/qommon/form.py
488 488
                extra_attributes = ' '.join(['%s=%s' % x for x in widget.content_extra_attributes.items()])
489 489
            r += htmltext('<td><div class="%s"><div class="content" %s>' % (classnames, extra_attributes))
490 490
            r += widget.render_content()
491
            r += widget.render_error(widget.get_error())
491 492
            r += htmltext('</div></div></td>')
492 493
        r += htmltext('</tr>\n')
493 494
        return r.getvalue()
wcs/qommon/static/css/dc2/admin.scss
1089 1089
div.ComputedExpressionWidget div.content select,
1090 1090
div.ConditionWidget div.content select {
1091 1091
	width: 2em;
1092
	padding: 4px 2em 4px 1ex;
1092
	padding: 5px 2em 5px 1ex;
1093 1093
	background-position: right 0.8rem center;
1094
	margin-left: -1px;
1094
	margin: 1px 0px 1px -1px;
1095 1095
	text-indent: -10000px;
1096 1096
	background-image: url(gear.svg);
1097 1097
	position: relative;
......
1116 1116
	height: 1.8em;
1117 1117
}
1118 1118

  
1119
.PostConditionsTableWidget td {
1120
	vertical-align: top;
1121
}
1122

  
1119 1123
ul#field-filter,
1120 1124
ul.columns-filter {
1121 1125
	list-style: none;
1122
-