2772 |
2772 |
attach = AddAttachmentWorkflowStatusItem()
|
2773 |
2773 |
attach.id = '_attach'
|
2774 |
2774 |
attach.by = ['_submitter']
|
|
2775 |
assert attach.attach_to_history == True
|
2775 |
2776 |
st1.items.append(attach)
|
2776 |
2777 |
attach.parent = st1
|
2777 |
2778 |
wf.store()
|
... | ... | |
2813 |
2814 |
st1 = wf.add_status('Status1', 'st1')
|
2814 |
2815 |
attach = AddAttachmentWorkflowStatusItem()
|
2815 |
2816 |
attach.varname = 'attached_doc'
|
|
2817 |
assert attach.attach_to_history == True
|
2816 |
2818 |
attach.id = '_attach'
|
2817 |
2819 |
attach.by = ['_submitter']
|
2818 |
2820 |
st1.items.append(attach)
|
... | ... | |
2866 |
2868 |
assert content_disposition.split(';')[0] == 'attachment'
|
2867 |
2869 |
assert resp.request.environ['PATH_INFO'].endswith(attachment_variable.filename)
|
2868 |
2870 |
|
|
2871 |
# do not show in history, only in substitution variables
|
|
2872 |
attach.attach_to_history = False
|
|
2873 |
wf.store()
|
|
2874 |
formdef.data_class().wipe()
|
|
2875 |
|
|
2876 |
resp = login(get_app(pub), username='foo', password='foo').get('/test/')
|
|
2877 |
resp = resp.forms[0].submit('submit')
|
|
2878 |
resp = resp.forms[0].submit('submit')
|
|
2879 |
resp = resp.follow()
|
|
2880 |
assert 'The form has been recorded' in resp.body
|
|
2881 |
resp.forms[0]['attachment_attach'] = Upload('test.txt', 'foobar', 'text/plain')
|
|
2882 |
resp = resp.forms[0].submit('button_attach')
|
|
2883 |
assert formdef.data_class().count() == 1
|
|
2884 |
formdata = formdef.data_class().select()[0]
|
|
2885 |
assert formdata.evolution[-1].parts[0].__class__.__name__ == 'AttachmentEvolutionPart'
|
|
2886 |
attachment = formdata.evolution[-1].parts[0]
|
|
2887 |
assert attachment.content_type == 'text/plain'
|
|
2888 |
assert attachment.orig_filename == 'test.txt'
|
|
2889 |
|
|
2890 |
resp = resp.follow() # back to form page
|
|
2891 |
# no link to the document
|
|
2892 |
assert 'test.txt' not in resp.body
|
|
2893 |
# substitution variable is ok
|
|
2894 |
variables = formdef.data_class().select()[0].get_substitution_variables()
|
|
2895 |
assert 'attachments' in variables
|
|
2896 |
attachments = variables['attachments']
|
|
2897 |
assert attachments is not None
|
|
2898 |
doc = attachments.attached_doc
|
|
2899 |
# cannot download the document
|
|
2900 |
resp = login(get_app(pub), username='foo', password='foo').get(doc.url, status=404)
|
|
2901 |
|
2869 |
2902 |
def test_formdata_attachment_download_to_backoffice_file_field(pub):
|
2870 |
2903 |
create_user(pub)
|
2871 |
2904 |
wf = Workflow(name='status')
|