|
|
|
@ -21,7 +21,12 @@ from wcs.qommon.misc import ConnectionError
|
|
|
|
|
from wcs.wf.create_formdata import Mapping
|
|
|
|
|
from wcs.wf.export_to_model import transform_to_pdf
|
|
|
|
|
from wcs.wf.form import WorkflowFormFieldsFormDef
|
|
|
|
|
from wcs.workflows import ContentSnapshotPart, Workflow, WorkflowBackofficeFieldsFormDef
|
|
|
|
|
from wcs.workflows import (
|
|
|
|
|
AttachmentEvolutionPart,
|
|
|
|
|
ContentSnapshotPart,
|
|
|
|
|
Workflow,
|
|
|
|
|
WorkflowBackofficeFieldsFormDef,
|
|
|
|
|
)
|
|
|
|
|
from wcs.wscalls import NamedWsCall
|
|
|
|
|
|
|
|
|
|
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
|
|
|
@ -258,7 +263,7 @@ def test_formdata_attachment_download_to_backoffice_file_field_only(pub):
|
|
|
|
|
attach = st1.add_action('addattachment', id='_attach')
|
|
|
|
|
attach.by = ['_submitter']
|
|
|
|
|
attach.backoffice_filefield_id = 'bo1'
|
|
|
|
|
attach.attach_to_history = False # store only in backoffice field
|
|
|
|
|
attach.attach_to_history = False # do not display in history
|
|
|
|
|
wf.store()
|
|
|
|
|
|
|
|
|
|
assert attach.get_backoffice_filefield_options() == [('bo1', 'bo field 1', 'bo1')]
|
|
|
|
@ -291,11 +296,56 @@ def test_formdata_attachment_download_to_backoffice_file_field_only(pub):
|
|
|
|
|
assert bo1.content_type == 'text/plain'
|
|
|
|
|
assert bo1.get_content() == b'foobar'
|
|
|
|
|
|
|
|
|
|
# but nothing in history
|
|
|
|
|
# nothing displayed in history
|
|
|
|
|
resp = resp.follow()
|
|
|
|
|
assert 'resp.text' not in resp.text
|
|
|
|
|
assert len(formdata.evolution) == 2
|
|
|
|
|
assert len(formdata.evolution[0].parts) == 1
|
|
|
|
|
assert isinstance(formdata.evolution[0].parts[0], ContentSnapshotPart)
|
|
|
|
|
assert formdata.evolution[1].parts is None
|
|
|
|
|
|
|
|
|
|
# but attachment stored
|
|
|
|
|
assert isinstance(formdata.evolution[1].parts[0], AttachmentEvolutionPart)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_formdata_attachment_stored(pub):
|
|
|
|
|
create_user(pub)
|
|
|
|
|
wf = Workflow(name='status')
|
|
|
|
|
st1 = wf.add_status('Status1', 'st1')
|
|
|
|
|
attach = st1.add_action('addattachment', id='_attach')
|
|
|
|
|
attach.by = ['_submitter']
|
|
|
|
|
attach.backoffice_filefield_id = None # do not store as backoffice field
|
|
|
|
|
attach.attach_to_history = False # do not display in history
|
|
|
|
|
wf.store()
|
|
|
|
|
|
|
|
|
|
FormDef.wipe()
|
|
|
|
|
formdef = FormDef()
|
|
|
|
|
formdef.name = 'test'
|
|
|
|
|
formdef.workflow_id = wf.id
|
|
|
|
|
formdef.fields = []
|
|
|
|
|
formdef.store()
|
|
|
|
|
formdef.data_class().wipe()
|
|
|
|
|
|
|
|
|
|
resp = login(get_app(pub), username='foo', password='foo').get('/test/')
|
|
|
|
|
resp = resp.forms[0].submit('submit')
|
|
|
|
|
assert 'Check values then click submit.' in resp.text
|
|
|
|
|
resp = resp.forms[0].submit('submit')
|
|
|
|
|
assert resp.status_int == 302
|
|
|
|
|
resp = resp.follow()
|
|
|
|
|
assert 'The form has been recorded' in resp.text
|
|
|
|
|
|
|
|
|
|
resp.forms[0]['attachment_attach$file'] = Upload('test.txt', b'foobar', 'text/plain')
|
|
|
|
|
resp = resp.forms[0].submit('button_attach')
|
|
|
|
|
|
|
|
|
|
# nothing displayed in history
|
|
|
|
|
resp = resp.follow()
|
|
|
|
|
assert 'resp.text' not in resp.text
|
|
|
|
|
formdata = formdef.data_class().select()[0]
|
|
|
|
|
assert len(formdata.evolution) == 2
|
|
|
|
|
assert len(formdata.evolution[0].parts) == 1
|
|
|
|
|
assert isinstance(formdata.evolution[0].parts[0], ContentSnapshotPart)
|
|
|
|
|
|
|
|
|
|
# but attachment stored
|
|
|
|
|
assert isinstance(formdata.evolution[1].parts[0], AttachmentEvolutionPart)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_formdata_attachment_file_options(pub):
|
|
|
|
|