0001-dataviz-display-warning-message-when-dataviz-has-no-.patch
combo/apps/dataviz/models.py | ||
---|---|---|
161 | 161 | |
162 | 162 |
def get_cell_extra_context(self, context): |
163 | 163 |
ctx = super(ChartNgCell, self).get_cell_extra_context(context) |
164 |
if self.chart_type == 'table': |
|
164 |
if self.chart_type == 'table' and self.cached_json:
|
|
165 | 165 |
try: |
166 | 166 |
chart = self.get_chart(raise_if_not_cached=not(context.get('synchronous'))) |
167 | 167 |
except UnsupportedDataSet: |
combo/apps/dataviz/templates/combo/chartngcell.html | ||
---|---|---|
1 | 1 |
{% load i18n %} |
2 | 2 |
{% if cell.title %}<h2>{{cell.title}}</h2>{% endif %} |
3 |
{% if cell.chart_type == "table" %} |
|
3 |
{% if not cell.cached_json %} |
|
4 |
<div class="warningnotice">{% trans "Unavailable data." %}</div> |
|
5 |
{% elif cell.chart_type == "table" %} |
|
4 | 6 |
{{table|safe}} |
5 | 7 |
{% else %} |
6 | 8 |
<div style="min-height: {{cell.height}}px"> |
tests/test_dataviz.py | ||
---|---|---|
428 | 428 |
resp = app.get('/api/dataviz/graph/1/?width=400', status=200) |
429 | 429 |
assert '>10.0%<' in resp.text |
430 | 430 | |
431 |
# cell with missing cached_json (probably after import and missing |
|
432 |
# bijoe visualisation) |
|
433 |
cell.chart_type = 'table' |
|
434 |
cell.save() |
|
435 |
ChartNgCell.objects.filter(id=cell.id).update(cached_json={}) |
|
436 |
resp = app.get('/') |
|
437 |
assert 'warningnotice' in resp.text |
|
438 | ||
431 | 439 | |
432 | 440 |
def test_chartng_cell_manager(app, admin_user): |
433 | 441 |
page = Page(title='One', slug='index') |
434 |
- |