workflows: model_file display in inspect view (#34626)

This commit is contained in:
Lauréline Guérin 2020-06-30 22:40:51 +02:00
parent 508269f347
commit cedb3d2cf0
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 27 additions and 0 deletions

View File

@ -26,10 +26,12 @@ from django.utils.six.moves.urllib import parse as urlparse
from webtest import Upload
from quixote import cleanup, get_publisher, get_response
from quixote.http_request import Upload as QuixoteUpload
from wcs.qommon import ods
from wcs.api_utils import sign_url
from wcs.qommon import errors, sessions
from wcs.qommon.form import PicklableUpload
from wcs.qommon.form import UploadedFile
from wcs.qommon.ident.password_accounts import PasswordAccount
from wcs.qommon.http_request import HTTPRequest
from wcs.qommon.substitution import CompatibilityNamesDict
@ -41,6 +43,7 @@ from wcs.workflows import (Workflow, CommentableWorkflowStatusItem,
WorkflowBackofficeFieldsFormDef)
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
from wcs.wf.dispatch import DispatchWorkflowStatusItem
from wcs.wf.export_to_model import ExportToModel
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
from wcs.wf.jump import JumpWorkflowStatusItem
from wcs.wf.wscall import WebserviceCallStatusItem
@ -5820,6 +5823,26 @@ def test_workflow_inspect_page(pub):
'<li>Foo Bar 3 → None</li>'
'<li>#unknown → foobar</li></ul>') in resp.text
st3 = workflow.add_status('Status3', 'st3')
export_to = ExportToModel()
export_to.convert_to_pdf = False
export_to.label = 'create doc'
upload = QuixoteUpload('/foo/test.rtf', content_type='application/rtf')
upload.fp = BytesIO()
upload.fp.write(b'HELLO WORLD')
upload.fp.seek(0)
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
export_to.id = '_export_to'
export_to.by = ['_submitter']
st3.items.append(export_to)
export_to.parent = st3
workflow.store()
resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id)
assert (
'<li><span class="parameter">Model:</span> '
'<a href="status/st3/items/_export_to/?file=model_file">test.rtf</a></li>') in resp.text
def test_workflow_comment_required(pub):
user = create_user(pub)

View File

@ -390,6 +390,10 @@ class ExportToModel(WorkflowStatusItem):
form.add(ComputedExpressionWidget, name='%sfilename' % prefix, title=_('File name'),
value=self.filename)
def get_model_file_parameter_view_value(self):
return htmltext('<a href="status/%s/items/%s/?file=model_file">%s</a>') % (
self.parent.id, self.id, self.model_file.base_filename)
def get_filename(self):
filename = None
if self.filename: