0001-backoffice-fix-fields-page-when-a-field-label-is-Non.patch
tests/admin_pages/test_form.py | ||
---|---|---|
1169 | 1169 |
assert '<h3 data-field-id="1">baz</h3>' in resp.text |
1170 | 1170 | |
1171 | 1171 | |
1172 |
def test_form_field_without_label(pub): |
|
1173 |
create_superuser(pub) |
|
1174 | ||
1175 |
FormDef.wipe() |
|
1176 |
formdef = FormDef() |
|
1177 |
formdef.name = 'form title' |
|
1178 |
formdef.fields = [fields.CommentField(id='1', label=None, type='comment')] |
|
1179 |
formdef.store() |
|
1180 | ||
1181 |
app = login(get_app(pub)) |
|
1182 |
app.get('/backoffice/forms/1/fields/', status=200) # ok, no error |
|
1183 | ||
1184 | ||
1172 | 1185 |
def test_form_delete_field(pub): |
1173 | 1186 |
create_superuser(pub) |
1174 | 1187 |
create_role() |
tests/test_fields.py | ||
---|---|---|
282 | 282 |
form = Form(use_tokens=False) |
283 | 283 |
field.add_to_form(form) |
284 | 284 |
assert re.match( # regex to handle different beautifulsoup behaviours |
285 |
'<div class="comment-field\s?">\n<p>Foo</p>\n<p>Bar</p>\n<p>Baz</p>\n</div>', |
|
285 |
r'<div class="comment-field\s?">\n<p>Foo</p>\n<p>Bar</p>\n<p>Baz</p>\n</div>',
|
|
286 | 286 |
str(BeautifulSoup(str(form.render())).find('div')), |
287 | 287 |
) |
288 | 288 |
wcs/fields.py | ||
---|---|---|
253 | 253 | |
254 | 254 |
@property |
255 | 255 |
def unhtmled_label(self): |
256 |
return force_str(html.unescape(force_text(re.sub('<.*?>', ' ', self.label))).strip()) |
|
256 |
return force_str(html.unescape(force_text(re.sub('<.*?>', ' ', self.label or ''))).strip())
|
|
257 | 257 | |
258 | 258 |
def get_admin_attributes(self): |
259 | 259 |
return ['label', 'type', 'condition'] |
260 |
- |