0001-misc-add-export-import-support-for-date-formdef-opti.patch
tests/test_formdef_import.py | ||
---|---|---|
215 | 215 |
assert formdef.workflow_options['foo'].filename == fd2.workflow_options['foo'].filename |
216 | 216 |
assert formdef.workflow_options['foo'].get_content() == fd2.workflow_options['foo'].get_content() |
217 | 217 | |
218 |
def test_workflow_options_with_date(): |
|
219 |
formdef = FormDef() |
|
220 |
formdef.name = 'foo' |
|
221 |
formdef.workflow_options = {'foo': time.strptime('2014-02-02', '%Y-%m-%d')} |
|
222 |
fd2 = assert_xml_import_export_works(formdef) |
|
223 |
assert formdef.workflow_options['foo'] == fd2.workflow_options['foo'] |
|
224 | ||
225 | ||
218 | 226 |
def test_workflow_reference(): |
219 | 227 |
Workflow.wipe() |
220 | 228 |
FormDef.wipe() |
wcs/formdef.py | ||
---|---|---|
939 | 939 |
ET.SubElement(element, 'content_type').text = ( |
940 | 940 |
option_value.content_type or 'application/octet-stream') |
941 | 941 |
ET.SubElement(element, 'content').text = base64.b64encode(option_value.get_content()) |
942 |
elif isinstance(option_value, time.struct_time): |
|
943 |
element.text = time.strftime('%Y-%m-%d', option_value) |
|
944 |
element.attrib['type'] = 'date' |
|
942 | 945 |
else: |
943 | 946 |
pass # TODO: extend support to other types |
944 | 947 | |
... | ... | |
1053 | 1056 |
formdef.workflow_options = {} |
1054 | 1057 |
for option in tree.findall('options/option'): |
1055 | 1058 |
option_value = None |
1056 |
if option.text: |
|
1059 |
if option.attrib.get('type') == 'date': |
|
1060 |
option_value = time.strptime(option.text, '%Y-%m-%d') |
|
1061 |
elif option.text: |
|
1057 | 1062 |
option_value = option.text.encode(charset) |
1058 | 1063 |
elif option.findall('filename'): |
1059 | 1064 |
filename = option.find('filename').text |
1060 |
- |