Projet

Général

Profil

0001-misc-mention-that-Python-usage-is-deprecated-next-to.patch

Frédéric Péters, 27 décembre 2022 16:11

Télécharger (10,8 ko)

Voir les différences:

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(-)
tests/admin_pages/test_datasource.py
235 235
        ('json', False, 'JSON URL'),
236 236
        ('jsonp', False, 'JSONP URL'),
237 237
        ('geojson', False, 'GeoJSON URL'),
238
        ('python', False, 'Python Expression'),
238
        ('python', False, 'Python Expression (deprecated)'),
239 239
        ('jsonvalue', False, 'JSON Expression'),
240 240
    ]
241 241

  
tests/admin_pages/test_form.py
1912 1912
    assert FormDef.get(formdef.id).fields[0].prefill == {'type': 'string', 'value': 'test', 'locked': False}
1913 1913

  
1914 1914
    resp = app.get('/backoffice/forms/1/fields/1/')
1915
    resp.form['prefill$type'] = 'Python Expression'
1915
    resp.form['prefill$type'] = 'Python Expression (deprecated)'
1916 1916
    resp.form['prefill$value_formula'] = 'True'
1917 1917
    resp = resp.form.submit('submit').follow()
1918 1918
    assert FormDef.get(formdef.id).fields[0].prefill == {'type': 'formula', 'value': 'True', 'locked': False}
......
1929 1929

  
1930 1930
    # check error handling
1931 1931
    resp = app.get('/backoffice/forms/1/fields/1/')
1932
    resp.form['prefill$type'] = 'Python Expression'
1932
    resp.form['prefill$type'] = 'Python Expression (deprecated)'
1933 1933
    resp.form['prefill$value_formula'] = ':'
1934 1934
    resp = resp.form.submit('submit')
1935 1935
    assert 'invalid expression: unexpected EOF while parsing' in resp.text
......
1961 1961
    assert resp.forms[0]['prefill$type'].options == [
1962 1962
        ('None', True, 'None'),
1963 1963
        ('String / Template', False, 'String / Template'),
1964
        ('Python Expression', False, 'Python Expression'),
1964
        ('Python Expression (deprecated)', False, 'Python Expression (deprecated)'),
1965 1965
        ('User Field', False, 'User Field'),
1966 1966
        ('Geolocation', False, 'Geolocation'),
1967 1967
    ]
......
2114 2114
        ('None', True, 'None'),
2115 2115
        ('json', False, 'JSON URL'),
2116 2116
        ('jsonp', False, 'JSONP URL'),
2117
        ('python', False, 'Python Expression'),
2117
        ('python', False, 'Python Expression (deprecated)'),
2118 2118
        ('jsonvalue', False, 'JSON Expression'),
2119 2119
    ]
2120 2120
    resp = resp.form.submit('submit').follow()
......
2131 2131
        ('foobar', False, 'Foobar'),
2132 2132
        ('json', False, 'JSON URL'),
2133 2133
        ('jsonp', False, 'JSONP URL'),
2134
        ('python', False, 'Python Expression'),
2134
        ('python', False, 'Python Expression (deprecated)'),
2135 2135
        ('jsonvalue', False, 'JSON Expression'),
2136 2136
    ]
2137 2137
    resp.form['data_mode'].value = 'data-source'
......
2151 2151
        ('foobar', True, 'Foobar'),
2152 2152
        ('json', False, 'JSON URL'),
2153 2153
        ('jsonp', False, 'JSONP URL'),
2154
        ('python', False, 'Python Expression'),
2154
        ('python', False, 'Python Expression (deprecated)'),
2155 2155
        ('jsonvalue', False, 'JSON Expression'),
2156 2156
    ]
2157 2157

  
......
2171 2171
        ('foobar', True, 'Foobar'),
2172 2172
        ('json', False, 'JSON URL'),
2173 2173
        ('jsonp', False, 'JSONP URL'),
2174
        ('python', False, 'Python Expression'),
2174
        ('python', False, 'Python Expression (deprecated)'),
2175 2175
        ('jsonvalue', False, 'JSON Expression'),
2176 2176
    ]
2177 2177
    assert (
......
2361 2361
    assert resp.forms[0]['prefill$type'].options == [
2362 2362
        ('None', True, 'None'),
2363 2363
        ('String / Template', False, 'String / Template'),
2364
        ('Python Expression', False, 'Python Expression'),
2364
        ('Python Expression (deprecated)', False, 'Python Expression (deprecated)'),
2365 2365
    ]
2366 2366

  
2367 2367
    # change configuration for datasource
......
2816 2816
    resp = app.get('/backoffice/forms/1/fields/0/')
2817 2817
    assert resp.form['condition$type'].options == [
2818 2818
        ('django', False, 'Django Expression'),
2819
        ('python', False, 'Python Expression'),
2819
        ('python', False, 'Python Expression (deprecated)'),
2820 2820
    ]
2821 2821

  
2822 2822
    pub.site_options.set('options', 'disable-python-expressions', 'true')
tests/admin_pages/test_workflow.py
2501 2501
        ('Latest arrival in status', False, 'Latest arrival in status'),
2502 2502
        ('Arrival in final status', False, 'Arrival in final status'),
2503 2503
        ('String / Template', False, 'String / Template'),
2504
        ('Python expression', False, 'Python expression'),
2504
        ('Python Expression (deprecated)', False, 'Python Expression (deprecated)'),
2505 2505
    ]
2506 2506

  
2507 2507
    pub.site_options.set('options', 'disable-python-expressions', 'true')
......
2905 2905
    assert resp.form['mappings$element0$expression$type'].options == [
2906 2906
        ('text', False, 'Text'),
2907 2907
        ('template', False, 'Template'),
2908
        ('python', False, 'Python Expression'),
2908
        ('python', False, 'Python Expression (deprecated)'),
2909 2909
    ]
2910 2910

  
2911 2911
    pub.site_options.set('options', 'disable-python-expressions', 'true')
wcs/admin/mail_templates.py
241 241
        form.add(
242 242
            WidgetList,
243 243
            'attachments',
244
            title=_('Attachments (templates or Python expressions)'),
244
            title=_('Attachments (templates)'),
245 245
            element_type=StringWidget,
246 246
            value=self.mail_template.attachments,
247 247
            add_element_label=_('Add attachment'),
wcs/data_sources.py
160 160
        if 'geojson' in allowed_source_types:
161 161
            generic_options.append(('geojson', _('GeoJSON URL'), 'geojson'))
162 162
        if 'python' in allowed_source_types:
163
            generic_options.append(('formula', _('Python Expression'), 'python'))
163
            generic_options.append(('formula', _('Python Expression (deprecated)'), 'python'))
164 164
        elif value.get('type') == 'formula':
165 165
            generic_options.append(('formula', _('Python Expression (deprecated)'), 'python'))
166 166
        if 'jsonvalue' in allowed_source_types:
......
988 988
            'json': _('JSON'),
989 989
            'jsonp': _('JSONP'),
990 990
            'geojson': _('GeoJSON'),
991
            'formula': _('Python Expression'),
991
            'formula': _('Python Expression (deprecated)'),
992 992
            'jsonvalue': _('JSON Expression'),
993 993
        }
994 994
        data_source_type = self.data_source.get('type')
wcs/fields.py
118 118
            ('string', _('String / Template')),
119 119
        ]
120 120
        if not get_publisher().has_site_option('disable-python-expressions'):
121
            options.append(('formula', _('Python Expression')))
121
            options.append(('formula', _('Python Expression (deprecated)')))
122 122
        options += [
123 123
            ('user', _('User Field')),
124 124
            ('geolocation', _('Geolocation')),
......
827 827
            'json': _('JSON URL'),
828 828
            'jsonp': _('JSONP URL'),
829 829
            'geojson': _('GeoJSON URL'),
830
            'formula': _('Python Expression'),
830
            'formula': _('Python Expression (deprecated)'),
831 831
            'jsonvalue': _('JSON Expression'),
832 832
        }
833 833
        if value.get('type') in data_source_types:
wcs/qommon/form.py
3343 3343
            ('template', _('Template'), 'template'),
3344 3344
        ]
3345 3345
        if self.allow_python and not get_publisher().has_site_option('disable-python-expressions'):
3346
            options.append(('python', _('Python Expression'), 'python'))
3346
            options.append(('python', _('Python Expression (deprecated)'), 'python'))
3347 3347

  
3348 3348
        self.add(
3349 3349
            StringWidget,
......
3469 3469
        if kwargs.get('allow_python', True) and not get_publisher().has_site_option(
3470 3470
            'disable-python-expressions'
3471 3471
        ):
3472
            options.append(('python', _('Python Expression'), 'python'))
3472
            options.append(('python', _('Python Expression (deprecated)'), 'python'))
3473 3473

  
3474 3474
        self.add(
3475 3475
            StringWidget,
wcs/workflows.py
1599 1599
            ('latest-arrival', _('Latest arrival in status')),
1600 1600
            ('finalized', _('Arrival in final status')),
1601 1601
            ('template', _('String / Template')),
1602
            ('python', _('Python expression')),
1602
            ('python', _('Python Expression (deprecated)')),
1603 1603
        ]
1604 1604
        return collections.OrderedDict(options)
1605 1605

  
......
1653 1653
            hint=_('This should produce a date; it will only apply to open forms.'),
1654 1654
            attrs={
1655 1655
                'data-dynamic-display-child-of': 'anchor',
1656
                'data-dynamic-display-value': _('Python expression'),
1656
                'data-dynamic-display-value': _('Python Expression (deprecated)'),
1657 1657
            },
1658 1658
        )
1659 1659

  
1660
-