From d588acdf5b0188fd10d8768ee2601cb058875168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 24 Oct 2016 21:31:14 +0200 Subject: [PATCH] admin: note when a data source has additional keys (#13725) --- tests/test_admin_pages.py | 9 +++++++++ wcs/admin/data_sources.py | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/test_admin_pages.py b/tests/test_admin_pages.py index bcf88af..8705a6a 100644 --- a/tests/test_admin_pages.py +++ b/tests/test_admin_pages.py @@ -3376,6 +3376,15 @@ def test_data_sources_view(pub): assert resp.body.count('
  • ') < 100 assert '
  • ...
  • ' in resp.body + data_source.data_source = {'type': 'formula', 'value': repr([ + {'id': 'a', 'text': 'bbb', 'foo': 'bar1'}, + {'id': 'b', 'text': 'bbb', 'foo': 'bar2'}, + ])} + data_source.store() + resp = app.get('/backoffice/settings/data-sources/%s/' % data_source.id) + assert 'Preview' in resp.body + assert 'Additional keys are available: foo' in resp.body + def test_data_sources_edit(pub): create_superuser(pub) NamedDataSource.wipe() diff --git a/wcs/admin/data_sources.py b/wcs/admin/data_sources.py index afc4e84..bd68da3 100644 --- a/wcs/admin/data_sources.py +++ b/wcs/admin/data_sources.py @@ -129,6 +129,7 @@ class NamedDataSourcePage(Directory): r += htmltext('

    %s

    ') % _('Preview') r += htmltext('
    ') + r += htmltext('') + additional_keys -= set(['id', 'text']) + if additional_keys: + r += htmltext('

    Additional keys are available: %s.

    ') % ( + ', '.join(sorted(additional_keys))) + r += htmltext('') else: # the data source field is required so this should never happen r += htmltext('

    %s

    ') % _('Not configured') -- 2.10.1