formdef: allow empty <description/> tags on import (#17291)
This commit is contained in:
parent
12bfec671f
commit
1668b6b7cc
|
@ -65,6 +65,16 @@ def test_text_attributes():
|
|||
f2 = assert_json_import_export_works(formdef)
|
||||
assert f2.url_name == formdef.url_name
|
||||
|
||||
def test_empty_description_tag():
|
||||
formdef = FormDef()
|
||||
formdef.name = 'empty'
|
||||
assert_xml_import_export_works(formdef)
|
||||
export = ET.tostring(export_to_indented_xml(formdef))
|
||||
# add empty description tag
|
||||
export = export.replace(b'<name>empty</name>', b'<name>empty</name><description></description>')
|
||||
formdef2 = FormDef.import_from_xml_tree(ET.fromstring(export))
|
||||
assert not formdef2.description
|
||||
|
||||
def test_boolean_attributes():
|
||||
formdef = FormDef()
|
||||
formdef.name = 'Foo'
|
||||
|
|
|
@ -1059,7 +1059,7 @@ class FormDef(StorableObject):
|
|||
formdef.id = tree.attrib.get('id')
|
||||
for text_attribute in list(cls.TEXT_ATTRIBUTES):
|
||||
value = tree.find(text_attribute)
|
||||
if value is None:
|
||||
if value is None or value.text is None:
|
||||
continue
|
||||
setattr(formdef, text_attribute, force_str(value.text))
|
||||
|
||||
|
|
Loading…
Reference in New Issue