0001-workflows-check-file-type-with-hasattr-for-backoffic.patch
tests/test_workflows.py | ||
---|---|---|
1938 | 1938 | |
1939 | 1939 |
formdata = formdef.data_class().get(formdata.id) |
1940 | 1940 |
assert formdata.data['bo1'].base_filename == 'test.jpeg' |
1941 |
assert formdata.data['bo1'].content_type == 'image/jpeg' |
|
1942 |
assert formdata.data['bo1'].get_content() == open(os.path.join(os.path.dirname(__file__), |
|
1943 |
'image-with-gps-data.jpeg')).read() |
|
1944 | ||
1945 |
# same test with PicklableUpload wcs.qommon.form |
|
1946 |
from wcs.qommon.form import PicklableUpload as PicklableUpload2 |
|
1947 |
upload2 = PicklableUpload2('test2.odt', 'application/vnd.oasis.opendocument.text') |
|
1948 |
upload2.receive([open(os.path.join(os.path.dirname(__file__), 'template.odt')).read()]) |
|
1949 |
formdata = formdef.data_class()() |
|
1950 |
formdata.data = {'00': upload2} |
|
1951 |
formdata.just_created() |
|
1952 |
formdata.store() |
|
1953 |
pub.substitutions.feed(formdata) |
|
1954 |
item.perform(formdata) |
|
1955 |
formdata = formdef.data_class().get(formdata.id) |
|
1956 |
assert formdata.data['bo1'].base_filename == 'test2.odt' |
|
1957 |
assert formdata.data['bo1'].content_type == 'application/vnd.oasis.opendocument.text' |
|
1958 |
assert formdata.data['bo1'].get_content() == open(os.path.join(os.path.dirname(__file__), |
|
1959 |
'template.odt')).read() |
|
1941 | 1960 | |
1942 | 1961 |
# check storing response as attachment |
1943 | 1962 |
pub.substitutions.feed(formdata) |
wcs/wf/backoffice_fields.py | ||
---|---|---|
88 | 88 |
if isinstance(new_value, PicklableUpload): |
89 | 89 |
return new_value |
90 | 90 | |
91 |
if hasattr(new_value, 'base_filename'): |
|
92 |
upload = PicklableUpload(new_value.base_filename, |
|
93 |
new_value.content_type or 'application/octet-stream') |
|
94 |
upload.receive([new_value.get_content()]) |
|
95 |
return upload |
|
96 | ||
91 | 97 |
if isinstance(new_value, NamedAttachmentsSubstitutionProxy): |
92 | 98 |
upload = PicklableUpload(new_value.filename, new_value.content_type) |
93 | 99 |
upload.receive([new_value.content]) |
94 |
- |