snapshot: workflow variables are not editable (#57501)
gitea-wip/wcs/pipeline/head There was a failure building this commit Details

This commit is contained in:
Lauréline Guérin 2021-10-07 10:29:38 +02:00
parent ae06861242
commit ca121d4bf1
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 27 additions and 1 deletions

View File

@ -16,7 +16,7 @@ from wcs.qommon.form import UploadedFile
from wcs.qommon.misc import localstrftime
from wcs.wf.export_to_model import ExportToModel
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
from wcs.workflows import Workflow
from wcs.workflows import Workflow, WorkflowVariablesFieldsFormDef
from wcs.wscalls import NamedWsCall
from .admin_pages.test_all import create_role, create_superuser
@ -679,6 +679,30 @@ def test_snaphost_workflow_status_item_comments(pub):
]
def test_snapshot_workflow_variable(pub):
create_superuser(pub)
create_role(pub)
Workflow.wipe()
workflow = Workflow(name='test')
workflow.store()
workflow.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=workflow)
workflow.variables_formdef.fields = [
StringField(id='0', label='foo', type='string', varname='foo'),
]
workflow.store()
app = login(get_app(pub))
snapshot = pub.snapshot_class.get_latest('workflow', workflow.id)
resp = app.get(
'/backoffice/workflows/%s/history/%s/view/variables/fields/0/' % (workflow.id, snapshot.id)
)
assert '>Submit<' not in resp
resp = app.get('/backoffice/workflows/%s/history/%s/view/variables/fields/' % (workflow.id, snapshot.id))
assert 'This workflow is readonly' in resp.text
assert 'sortable readonly' in resp.text
@pytest.fixture
def size_limit(pub):
pub.snapshot_class.WCS_MAX_LEN = 100

View File

@ -394,6 +394,8 @@ class WorkflowVariablesFieldsFormDef(FormDef):
def __init__(self, workflow):
self.id = None
self.workflow = workflow
if self.workflow.is_readonly():
self.readonly = True
if workflow.variables_formdef and workflow.variables_formdef.fields:
self.fields = self.workflow.variables_formdef.fields
self.max_field_id = max(lax_int(x.id) for x in self.fields or [])