0001-admin-note-when-a-data-source-has-additional-keys-13.patch
tests/test_admin_pages.py | ||
---|---|---|
3376 | 3376 |
assert resp.body.count('<li>') < 100 |
3377 | 3377 |
assert '<li>...</li>' in resp.body |
3378 | 3378 | |
3379 |
data_source.data_source = {'type': 'formula', 'value': repr([ |
|
3380 |
{'id': 'a', 'text': 'bbb', 'foo': 'bar1'}, |
|
3381 |
{'id': 'b', 'text': 'bbb', 'foo': 'bar2'}, |
|
3382 |
])} |
|
3383 |
data_source.store() |
|
3384 |
resp = app.get('/backoffice/settings/data-sources/%s/' % data_source.id) |
|
3385 |
assert 'Preview' in resp.body |
|
3386 |
assert 'Additional keys are available: foo' in resp.body |
|
3387 | ||
3379 | 3388 |
def test_data_sources_edit(pub): |
3380 | 3389 |
create_superuser(pub) |
3381 | 3390 |
NamedDataSource.wipe() |
wcs/admin/data_sources.py | ||
---|---|---|
129 | 129 |
r += htmltext('<h3>%s</h3>') % _('Preview') |
130 | 130 |
r += htmltext('<div class="bo-block data-source-preview"><ul>') |
131 | 131 |
r += htmltext('<ul>') |
132 |
additional_keys = set() |
|
132 | 133 |
for item in items[:10]: |
133 | 134 |
if not isinstance(item.get('text'), str): |
134 | 135 |
r += htmltext('<li><tt>%s</tt>: <i>%s (%r)</i></li>') % ( |
... | ... | |
138 | 139 |
else: |
139 | 140 |
r += htmltext('<li><tt>%s</tt>: %s</li>') % ( |
140 | 141 |
item.get('id'), item.get('text')) |
142 |
additional_keys |= set(item.keys()) |
|
141 | 143 |
if len(items) > 10: |
142 | 144 |
r += htmltext('<li>...</li>') |
143 |
r += htmltext('</ul></div>') |
|
145 |
r += htmltext('</ul>') |
|
146 |
additional_keys -= set(['id', 'text']) |
|
147 |
if additional_keys: |
|
148 |
r += htmltext('<p>Additional keys are available: %s.</p>') % ( |
|
149 |
', '.join(sorted(additional_keys))) |
|
150 |
r += htmltext('</div>') |
|
144 | 151 |
else: |
145 | 152 |
# the data source field is required so this should never happen |
146 | 153 |
r += htmltext('<p class="infonotice">%s</p>') % _('Not configured') |
147 |
- |