backoffice: fix fields page when a field label is None (#51728)
This commit is contained in:
parent
4c6ec73981
commit
c72cc12a6e
|
@ -1169,6 +1169,19 @@ def test_form_new_field(pub):
|
|||
assert '<h3 data-field-id="1">baz</h3>' in resp.text
|
||||
|
||||
|
||||
def test_form_field_without_label(pub):
|
||||
create_superuser(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = [fields.CommentField(id='1', label=None, type='comment')]
|
||||
formdef.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
app.get('/backoffice/forms/1/fields/', status=200) # ok, no error
|
||||
|
||||
|
||||
def test_form_delete_field(pub):
|
||||
create_superuser(pub)
|
||||
create_role()
|
||||
|
|
|
@ -282,7 +282,7 @@ def test_comment():
|
|||
form = Form(use_tokens=False)
|
||||
field.add_to_form(form)
|
||||
assert re.match( # regex to handle different beautifulsoup behaviours
|
||||
'<div class="comment-field\s?">\n<p>Foo</p>\n<p>Bar</p>\n<p>Baz</p>\n</div>',
|
||||
r'<div class="comment-field\s?">\n<p>Foo</p>\n<p>Bar</p>\n<p>Baz</p>\n</div>',
|
||||
str(BeautifulSoup(str(form.render())).find('div')),
|
||||
)
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ class Field(object):
|
|||
|
||||
@property
|
||||
def unhtmled_label(self):
|
||||
return force_str(html.unescape(force_text(re.sub('<.*?>', ' ', self.label))).strip())
|
||||
return force_str(html.unescape(force_text(re.sub('<.*?>', ' ', self.label or ''))).strip())
|
||||
|
||||
def get_admin_attributes(self):
|
||||
return ['label', 'type', 'condition']
|
||||
|
|
Loading…
Reference in New Issue