From 5b45a9d4047ae87acf8372ab4ac3efd4406b280f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Tue, 27 Dec 2022 14:58:22 +0100
Subject: [PATCH] misc: mention that Python usage is deprecated next to Python
 options (#72083)

---
 tests/admin_pages/test_datasource.py |  2 +-
 tests/admin_pages/test_form.py       | 18 +++++++++---------
 tests/admin_pages/test_workflow.py   |  4 ++--
 wcs/admin/mail_templates.py          |  2 +-
 wcs/data_sources.py                  |  4 ++--
 wcs/fields.py                        |  4 ++--
 wcs/qommon/form.py                   |  4 ++--
 wcs/workflows.py                     |  4 ++--
 8 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/tests/admin_pages/test_datasource.py b/tests/admin_pages/test_datasource.py
index 59cc2a05a..18c9238e0 100644
--- a/tests/admin_pages/test_datasource.py
+++ b/tests/admin_pages/test_datasource.py
@@ -235,7 +235,7 @@ def test_data_sources_type_options(pub):
         ('json', False, 'JSON URL'),
         ('jsonp', False, 'JSONP URL'),
         ('geojson', False, 'GeoJSON URL'),
-        ('python', False, 'Python Expression'),
+        ('python', False, 'Python Expression (deprecated)'),
         ('jsonvalue', False, 'JSON Expression'),
     ]
 
diff --git a/tests/admin_pages/test_form.py b/tests/admin_pages/test_form.py
index 7765429bb..9cefaf6a8 100644
--- a/tests/admin_pages/test_form.py
+++ b/tests/admin_pages/test_form.py
@@ -1912,7 +1912,7 @@ def test_form_prefill_field(pub):
     assert FormDef.get(formdef.id).fields[0].prefill == {'type': 'string', 'value': 'test', 'locked': False}
 
     resp = app.get('/backoffice/forms/1/fields/1/')
-    resp.form['prefill$type'] = 'Python Expression'
+    resp.form['prefill$type'] = 'Python Expression (deprecated)'
     resp.form['prefill$value_formula'] = 'True'
     resp = resp.form.submit('submit').follow()
     assert FormDef.get(formdef.id).fields[0].prefill == {'type': 'formula', 'value': 'True', 'locked': False}
@@ -1929,7 +1929,7 @@ def test_form_prefill_field(pub):
 
     # check error handling
     resp = app.get('/backoffice/forms/1/fields/1/')
-    resp.form['prefill$type'] = 'Python Expression'
+    resp.form['prefill$type'] = 'Python Expression (deprecated)'
     resp.form['prefill$value_formula'] = ':'
     resp = resp.form.submit('submit')
     assert 'invalid expression: unexpected EOF while parsing' in resp.text
@@ -1961,7 +1961,7 @@ def test_form_prefill_type_options(pub):
     assert resp.forms[0]['prefill$type'].options == [
         ('None', True, 'None'),
         ('String / Template', False, 'String / Template'),
-        ('Python Expression', False, 'Python Expression'),
+        ('Python Expression (deprecated)', False, 'Python Expression (deprecated)'),
         ('User Field', False, 'User Field'),
         ('Geolocation', False, 'Geolocation'),
     ]
@@ -2114,7 +2114,7 @@ def test_form_edit_item_field_data_source(pub):
         ('None', True, 'None'),
         ('json', False, 'JSON URL'),
         ('jsonp', False, 'JSONP URL'),
-        ('python', False, 'Python Expression'),
+        ('python', False, 'Python Expression (deprecated)'),
         ('jsonvalue', False, 'JSON Expression'),
     ]
     resp = resp.form.submit('submit').follow()
@@ -2131,7 +2131,7 @@ def test_form_edit_item_field_data_source(pub):
         ('foobar', False, 'Foobar'),
         ('json', False, 'JSON URL'),
         ('jsonp', False, 'JSONP URL'),
-        ('python', False, 'Python Expression'),
+        ('python', False, 'Python Expression (deprecated)'),
         ('jsonvalue', False, 'JSON Expression'),
     ]
     resp.form['data_mode'].value = 'data-source'
@@ -2151,7 +2151,7 @@ def test_form_edit_item_field_data_source(pub):
         ('foobar', True, 'Foobar'),
         ('json', False, 'JSON URL'),
         ('jsonp', False, 'JSONP URL'),
-        ('python', False, 'Python Expression'),
+        ('python', False, 'Python Expression (deprecated)'),
         ('jsonvalue', False, 'JSON Expression'),
     ]
 
@@ -2171,7 +2171,7 @@ def test_form_edit_item_field_data_source(pub):
         ('foobar', True, 'Foobar'),
         ('json', False, 'JSON URL'),
         ('jsonp', False, 'JSONP URL'),
-        ('python', False, 'Python Expression'),
+        ('python', False, 'Python Expression (deprecated)'),
         ('jsonvalue', False, 'JSON Expression'),
     ]
     assert (
@@ -2361,7 +2361,7 @@ def test_form_edit_items_field(pub):
     assert resp.forms[0]['prefill$type'].options == [
         ('None', True, 'None'),
         ('String / Template', False, 'String / Template'),
-        ('Python Expression', False, 'Python Expression'),
+        ('Python Expression (deprecated)', False, 'Python Expression (deprecated)'),
     ]
 
     # change configuration for datasource
@@ -2816,7 +2816,7 @@ def test_form_page_field_condition_types(pub):
     resp = app.get('/backoffice/forms/1/fields/0/')
     assert resp.form['condition$type'].options == [
         ('django', False, 'Django Expression'),
-        ('python', False, 'Python Expression'),
+        ('python', False, 'Python Expression (deprecated)'),
     ]
 
     pub.site_options.set('options', 'disable-python-expressions', 'true')
diff --git a/tests/admin_pages/test_workflow.py b/tests/admin_pages/test_workflow.py
index 372662870..e15ed1327 100644
--- a/tests/admin_pages/test_workflow.py
+++ b/tests/admin_pages/test_workflow.py
@@ -2501,7 +2501,7 @@ def test_workflows_global_actions_timeout_trigger_anchor_options(pub):
         ('Latest arrival in status', False, 'Latest arrival in status'),
         ('Arrival in final status', False, 'Arrival in final status'),
         ('String / Template', False, 'String / Template'),
-        ('Python expression', False, 'Python expression'),
+        ('Python Expression (deprecated)', False, 'Python Expression (deprecated)'),
     ]
 
     pub.site_options.set('options', 'disable-python-expressions', 'true')
@@ -2905,7 +2905,7 @@ def test_workflows_create_formdata_expression_types(pub):
     assert resp.form['mappings$element0$expression$type'].options == [
         ('text', False, 'Text'),
         ('template', False, 'Template'),
-        ('python', False, 'Python Expression'),
+        ('python', False, 'Python Expression (deprecated)'),
     ]
 
     pub.site_options.set('options', 'disable-python-expressions', 'true')
diff --git a/wcs/admin/mail_templates.py b/wcs/admin/mail_templates.py
index dd18fe398..2e048827b 100644
--- a/wcs/admin/mail_templates.py
+++ b/wcs/admin/mail_templates.py
@@ -241,7 +241,7 @@ class MailTemplatePage(Directory):
         form.add(
             WidgetList,
             'attachments',
-            title=_('Attachments (templates or Python expressions)'),
+            title=_('Attachments (templates)'),
             element_type=StringWidget,
             value=self.mail_template.attachments,
             add_element_label=_('Add attachment'),
diff --git a/wcs/data_sources.py b/wcs/data_sources.py
index 2b432a08c..70912275b 100644
--- a/wcs/data_sources.py
+++ b/wcs/data_sources.py
@@ -160,7 +160,7 @@ class DataSourceSelectionWidget(CompositeWidget):
         if 'geojson' in allowed_source_types:
             generic_options.append(('geojson', _('GeoJSON URL'), 'geojson'))
         if 'python' in allowed_source_types:
-            generic_options.append(('formula', _('Python Expression'), 'python'))
+            generic_options.append(('formula', _('Python Expression (deprecated)'), 'python'))
         elif value.get('type') == 'formula':
             generic_options.append(('formula', _('Python Expression (deprecated)'), 'python'))
         if 'jsonvalue' in allowed_source_types:
@@ -988,7 +988,7 @@ class NamedDataSource(XmlStorableObject):
             'json': _('JSON'),
             'jsonp': _('JSONP'),
             'geojson': _('GeoJSON'),
-            'formula': _('Python Expression'),
+            'formula': _('Python Expression (deprecated)'),
             'jsonvalue': _('JSON Expression'),
         }
         data_source_type = self.data_source.get('type')
diff --git a/wcs/fields.py b/wcs/fields.py
index 6cde227a6..b1fdb1071 100644
--- a/wcs/fields.py
+++ b/wcs/fields.py
@@ -118,7 +118,7 @@ class PrefillSelectionWidget(CompositeWidget):
             ('string', _('String / Template')),
         ]
         if not get_publisher().has_site_option('disable-python-expressions'):
-            options.append(('formula', _('Python Expression')))
+            options.append(('formula', _('Python Expression (deprecated)')))
         options += [
             ('user', _('User Field')),
             ('geolocation', _('Geolocation')),
@@ -827,7 +827,7 @@ class Field:
             'json': _('JSON URL'),
             'jsonp': _('JSONP URL'),
             'geojson': _('GeoJSON URL'),
-            'formula': _('Python Expression'),
+            'formula': _('Python Expression (deprecated)'),
             'jsonvalue': _('JSON Expression'),
         }
         if value.get('type') in data_source_types:
diff --git a/wcs/qommon/form.py b/wcs/qommon/form.py
index b1245e31f..6bd6246d4 100644
--- a/wcs/qommon/form.py
+++ b/wcs/qommon/form.py
@@ -3343,7 +3343,7 @@ class ComputedExpressionWidget(CompositeWidget):
             ('template', _('Template'), 'template'),
         ]
         if self.allow_python and not get_publisher().has_site_option('disable-python-expressions'):
-            options.append(('python', _('Python Expression'), 'python'))
+            options.append(('python', _('Python Expression (deprecated)'), 'python'))
 
         self.add(
             StringWidget,
@@ -3469,7 +3469,7 @@ class ConditionWidget(CompositeWidget):
         if kwargs.get('allow_python', True) and not get_publisher().has_site_option(
             'disable-python-expressions'
         ):
-            options.append(('python', _('Python Expression'), 'python'))
+            options.append(('python', _('Python Expression (deprecated)'), 'python'))
 
         self.add(
             StringWidget,
diff --git a/wcs/workflows.py b/wcs/workflows.py
index c1a709166..c2a4a435e 100644
--- a/wcs/workflows.py
+++ b/wcs/workflows.py
@@ -1599,7 +1599,7 @@ class WorkflowGlobalActionTimeoutTrigger(WorkflowGlobalActionTrigger):
             ('latest-arrival', _('Latest arrival in status')),
             ('finalized', _('Arrival in final status')),
             ('template', _('String / Template')),
-            ('python', _('Python expression')),
+            ('python', _('Python Expression (deprecated)')),
         ]
         return collections.OrderedDict(options)
 
@@ -1653,7 +1653,7 @@ class WorkflowGlobalActionTimeoutTrigger(WorkflowGlobalActionTrigger):
             hint=_('This should produce a date; it will only apply to open forms.'),
             attrs={
                 'data-dynamic-display-child-of': 'anchor',
-                'data-dynamic-display-value': _('Python expression'),
+                'data-dynamic-display-value': _('Python Expression (deprecated)'),
             },
         )
 
-- 
2.39.0

