Projet

Général

Profil

0001-admin-only-allow-geojson-in-named-data-sources-45655.patch

Frédéric Péters, 09 août 2020 11:27

Télécharger (4,34 ko)

Voir les différences:

Subject: [PATCH] admin: only allow geojson in named data sources (#45655)

 tests/test_datasources_admin_pages.py | 8 ++++++++
 tests/test_forms_admin_pages.py       | 4 ----
 wcs/admin/data_sources.py             | 1 +
 wcs/data_sources.py                   | 5 +++--
 4 files changed, 12 insertions(+), 6 deletions(-)
tests/test_datasources_admin_pages.py
81 81
    resp = resp.click('New Data Source')
82 82
    resp.forms[0]['name'] = 'a new data source'
83 83
    resp.forms[0]['description'] = 'description of the data source'
84

  
85
    assert resp.form['data_source$type'].options == [
86
        ('None', True, 'None'),
87
        ('json', False, 'JSON URL'),
88
        ('jsonp', False, 'JSONP URL'),
89
        ('geojson', False, 'GeoJSON URL'),
90
        ('python', False, 'Python Expression')
91
    ]
84 92
    resp.forms[0]['data_source$type'] = 'python'
85 93
    resp = resp.forms[0].submit('data_source$apply')
86 94
    resp.forms[0]['data_source$value'] = repr(
tests/test_forms_admin_pages.py
1435 1435
        (u'None', True, u'None'),
1436 1436
        (u'json', False, u'JSON URL'),
1437 1437
        (u'jsonp', False, u'JSONP URL'),
1438
        (u'geojson', False, u'GeoJSON URL'),
1439 1438
        (u'python', False, u'Python Expression')
1440 1439
    ]
1441 1440
    resp = resp.form.submit('submit').follow()
......
1450 1449
        (u'foobar', False, u'Foobar'),
1451 1450
        (u'json', False, u'JSON URL'),
1452 1451
        (u'jsonp', False, u'JSONP URL'),
1453
        (u'geojson', False, u'GeoJSON URL'),
1454 1452
        (u'python', False, u'Python Expression')
1455 1453
    ]
1456 1454
    resp.form['data_source$type'].value = 'foobar'
......
1467 1465
        (u'foobar', True, u'Foobar'),
1468 1466
        (u'json', False, u'JSON URL'),
1469 1467
        (u'jsonp', False, u'JSONP URL'),
1470
        (u'geojson', False, u'GeoJSON URL'),
1471 1468
        (u'python', False, u'Python Expression')
1472 1469
    ]
1473 1470

  
......
1481 1478
        (u'foobar', True, u'Foobar'),
1482 1479
        (u'json', False, u'JSON URL'),
1483 1480
        (u'jsonp', False, u'JSONP URL'),
1484
        (u'geojson', False, u'GeoJSON URL'),
1485 1481
        (u'python', False, u'Python Expression')
1486 1482
    ]
1487 1483

  
wcs/admin/data_sources.py
58 58
        form.add(DataSourceSelectionWidget, 'data_source',
59 59
                value=self.datasource.data_source,
60 60
                title=_('Data Source'),
61
                allow_geojson=True,
61 62
                allow_named_sources=False,
62 63
                required=True)
63 64
        form.add(DurationWidget, 'cache_duration',
wcs/data_sources.py
52 52

  
53 53
class DataSourceSelectionWidget(CompositeWidget):
54 54
    def __init__(self, name, value=None, allow_jsonp=True,
55
            allow_named_sources=True, **kwargs):
55
            allow_geojson=False, allow_named_sources=True, **kwargs):
56 56
        CompositeWidget.__init__(self, name, value, **kwargs)
57 57

  
58 58
        if not value:
......
72 72
        options.append(('json', _('JSON URL'), 'json'))
73 73
        if allow_jsonp:
74 74
            options.append(('jsonp', _('JSONP URL'), 'jsonp'))
75
        options.append(('geojson', _('GeoJSON URL'), 'geojson'))
75
        if allow_geojson:
76
            options.append(('geojson', _('GeoJSON URL'), 'geojson'))
76 77
        options.append(('formula', _('Python Expression'), 'python'))
77 78

  
78 79
        self.add(SingleSelectWidget, 'type', options=options, value=value.get('type'),
79
-