From fdd911c335f4cfa81806d79272d8d16280af5cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 20 Jun 2016 20:43:52 +0200 Subject: [PATCH] admin: don't display prefill option for backoffice fields (#11454) --- tests/test_admin_pages.py | 4 ++++ wcs/admin/workflows.py | 5 +++++ wcs/qommon/form.py | 5 +++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_admin_pages.py b/tests/test_admin_pages.py index 93cdcb5..4012a91 100644 --- a/tests/test_admin_pages.py +++ b/tests/test_admin_pages.py @@ -1691,6 +1691,10 @@ def test_workflows_backoffice_fields(pub): assert workflow.backoffice_fields_formdef.fields[0].id == 'bo1' assert workflow.backoffice_fields_formdef.fields[1].id == 'bo2' + # check there's no prefill field + resp = app.get('/backoffice/workflows/1/backoffice-fields/fields/bo2/') + assert not 'prefill$type' in resp.form.fields.keys() + # add a title field resp = app.get('/backoffice/workflows/1/backoffice-fields/fields/') resp.forms[0]['label'] = 'foobar3' diff --git a/wcs/admin/workflows.py b/wcs/admin/workflows.py index 8bbe5d8..114ca63 100644 --- a/wcs/admin/workflows.py +++ b/wcs/admin/workflows.py @@ -835,6 +835,11 @@ class WorkflowVariablesFieldDefPage(FieldDefPage): class WorkflowBackofficeFieldDefPage(FieldDefPage): section = 'workflows' + def form(self): + form = super(WorkflowBackofficeFieldDefPage, self).form() + form.remove('prefill') + return form + class WorkflowVariablesFieldsDirectory(FieldsDirectory): _q_exports = ['', 'update_order', 'new'] diff --git a/wcs/qommon/form.py b/wcs/qommon/form.py index ad1d6b9..1fec3b2 100644 --- a/wcs/qommon/form.py +++ b/wcs/qommon/form.py @@ -295,8 +295,9 @@ class Form(QuixoteForm): def remove(self, name): widget = self._names.get(name) - del self._names[name] - self.widgets.remove(widget) + if widget: + del self._names[name] + self.widgets.remove(widget) def get_all_widgets(self): l = QuixoteForm.get_all_widgets(self) -- 2.8.1