datasource: prefix additional keys by "properties_" (#49975)
and add geometry_coordinates, geometry_type
This commit is contained in:
parent
83a09fc38f
commit
115b0c8ef6
|
@ -230,7 +230,7 @@ def test_data_sources_view(pub):
|
|||
assert 'Preview' in resp.text
|
||||
assert 'foo' in resp.text
|
||||
assert 'bar' in resp.text
|
||||
assert 'Additional keys are available: label' in resp.text
|
||||
assert 'Additional keys are available: geometry_coordinates, geometry_type, properties_label' in resp.text
|
||||
|
||||
data_source.data_source = {'type': 'formula', 'value': '[str(x) for x in range(100)]'}
|
||||
data_source.store()
|
||||
|
|
|
@ -252,13 +252,15 @@ class NamedDataSourcePage(Directory):
|
|||
r += htmltext('<li><tt>%s</tt>: %s</li>') % (
|
||||
item.get('id'), item.get('text'))
|
||||
if data_source.get('type') == 'geojson':
|
||||
additional_keys |= set(item.get('properties', {}).keys())
|
||||
additional_keys.add('geometry_coordinates')
|
||||
additional_keys.add('geometry_type')
|
||||
additional_keys |= set('properties_%s' % k for k in item.get('properties', {}).keys())
|
||||
else:
|
||||
additional_keys |= set(item.keys())
|
||||
if len(items) > 10:
|
||||
r += htmltext('<li>...</li>')
|
||||
r += htmltext('</ul>')
|
||||
additional_keys -= set(['id', 'text'])
|
||||
additional_keys -= set(['id', 'text', 'properties_id', 'properties_text'])
|
||||
if additional_keys:
|
||||
r += htmltext('<p>%s %s</p>') % (_('Additional keys are available:'),
|
||||
', '.join(sorted(additional_keys)))
|
||||
|
|
Loading…
Reference in New Issue