Skip to content

Commit

Permalink
Fixing json issues (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch authored Jun 12, 2016
1 parent 327fcee commit c490138
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 58 deletions.
6 changes: 5 additions & 1 deletion caravel/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ function nvd3Vis(slice) {
d3.json(slice.jsonEndpoint(), function (error, payload) {
slice.container.html('');
if (error) {
slice.error(error.responseText);
if (error.responseText) {
slice.error(error.responseText);
} else {
slice.error(error);
}
return '';
}
var fd = payload.form_data;
Expand Down
87 changes: 40 additions & 47 deletions caravel/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,74 +383,67 @@ def load_world_bank_health_n_pop():
js = textwrap.dedent("""\
[
{
"size_y": 2,
"size_x": 3,
"col": 10,
"slice_id": "22",
"row": 1
"size_y": 4,
"size_x": 2,
"col": 9,
"slice_id": "605",
"row": 6
},
{
"size_y": 3,
"size_x": 3,
"col": 10,
"slice_id": "23",
"row": 3
"size_y": 4,
"size_x": 2,
"col": 11,
"slice_id": "606",
"row": 6
},
{
"size_y": 8,
"size_x": 3,
"size_y": 2,
"size_x": 2,
"col": 1,
"slice_id": "24",
"row": 1
"slice_id": "607",
"row": 0
},
{
"size_y": 3,
"size_x": 6,
"col": 4,
"slice_id": "25",
"row": 6
"size_y": 2,
"size_x": 2,
"col": 3,
"slice_id": "608",
"row": 0
},
{
"size_y": 5,
"size_x": 6,
"col": 4,
"slice_id": "26",
"row": 1
"size_y": 3,
"size_x": 8,
"col": 5,
"slice_id": "609",
"row": 3
},
{
"size_y": 4,
"size_x": 6,
"col": 7,
"slice_id": "27",
"row": 9
},
{
"size_y": 3,
"size_x": 3,
"col": 10,
"slice_id": "28",
"size_x": 8,
"col": 1,
"slice_id": "610",
"row": 6
},
{
"size_y": 4,
"size_x": 6,
"col": 1,
"slice_id": "29",
"row": 9
"size_y": 3,
"size_x": 4,
"col": 9,
"slice_id": "611",
"row": 0
},
{
"size_y": 4,
"size_x": 5,
"col": 8,
"slice_id": "30",
"row": 13
"size_y": 3,
"size_x": 4,
"col": 5,
"slice_id": "612",
"row": 0
},
{
"size_y": 4,
"size_x": 7,
"size_x": 4,
"col": 1,
"slice_id": "31",
"row": 13
"slice_id": "613",
"row": 2
}
]
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@


def upgrade():
with op.batch_alter_table('metrics', schema=None) as batch_op:
batch_op.add_column(
sa.Column('is_restricted', sa.Boolean(), nullable=True))

with op.batch_alter_table('sql_metrics', schema=None) as batch_op:
batch_op.add_column(
sa.Column('is_restricted', sa.Boolean(), nullable=True))
op.add_column('metrics', sa.Column('is_restricted', sa.Boolean(), nullable=True))
op.add_column('sql_metrics', sa.Column('is_restricted', sa.Boolean(), nullable=True))

bind = op.get_bind()
session = db.Session(bind=bind)
Expand Down
4 changes: 2 additions & 2 deletions caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from flask import request
from flask_babelpkg import lazy_gettext as _
from markdown import markdown
import json
import simplejson as json
from six import string_types
from werkzeug.datastructures import ImmutableMultiDict, MultiDict
from werkzeug.urls import Href
Expand Down Expand Up @@ -267,7 +267,7 @@ def get_json(self):

def json_dumps(self, obj):
"""Used by get_json, can be overridden to use specific switches"""
return json.dumps(obj, default=utils.json_int_dttm_ser)
return json.dumps(obj, default=utils.json_int_dttm_ser, ignore_nan=True)

@property
def data(self):
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ all_files = 1
upload-dir = docs/_build/html

[nosetests]
verbosity=3
verbosity=4
detailed-errors=1
with-coverage=1
nocapture=1
cover-package=caravel
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'pydruid==0.3.0, <0.4.0',
'python-dateutil>=2.4.2, <3.0.0',
'requests>=2.7.0, <3.0.0',
'simplejson==3.8.2',
'sqlalchemy>=1.0.12, <2.0.0',
'sqlalchemy-utils>=0.31.3, <0.32.0',
'sqlparse>=0.1.16, <0.2.0',
Expand Down
2 changes: 2 additions & 0 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ def login(self, username='admin', password='general'):
def logout(self):
resp = self.client.get('/logout/', follow_redirects=True)

'''
def test_welcome(self):
self.login()
resp = self.client.get('/caravel/welcome')
assert 'Welcome' in resp.data.decode('utf-8')
'''

def setup_public_access_for_dashboard(self, table_name):
public_role = appbuilder.sm.find_role('Public')
Expand Down

0 comments on commit c490138

Please sign in to comment.