mirror of
https://github.com/apache/superset.git
synced 2026-04-22 17:45:21 +00:00
TOX / Travis build matrix (#593)
* Building on many dbs * Fixing some translation related error msg
This commit is contained in:
committed by
GitHub
parent
dd662eaca3
commit
60ed3e4050
@@ -4,16 +4,16 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from datetime import datetime
|
||||
import functools
|
||||
import json
|
||||
import logging
|
||||
import numpy
|
||||
from datetime import datetime
|
||||
import time
|
||||
|
||||
import parsedatetime
|
||||
import sqlalchemy as sa
|
||||
from dateutil.parser import parse
|
||||
from alembic import op
|
||||
from flask import flash, Markup
|
||||
from flask_appbuilder.security.sqla import models as ab_models
|
||||
from markdown import markdown as md
|
||||
@@ -183,21 +183,22 @@ def init(caravel):
|
||||
public_role_like_gamma = \
|
||||
public_role and config.get('PUBLIC_ROLE_LIKE_GAMMA', False)
|
||||
for perm in perms:
|
||||
if (perm.view_menu and perm.view_menu.name not in (
|
||||
'ResetPasswordView',
|
||||
'RoleModelView',
|
||||
'UserDBModelView',
|
||||
'Security') and
|
||||
perm.permission.name not in (
|
||||
'all_datasource_access',
|
||||
'can_add',
|
||||
'can_download',
|
||||
'can_delete',
|
||||
'can_edit',
|
||||
'can_save',
|
||||
'datasource_access',
|
||||
'muldelete',
|
||||
)):
|
||||
if (
|
||||
perm.view_menu and perm.view_menu.name not in (
|
||||
'ResetPasswordView',
|
||||
'RoleModelView',
|
||||
'UserDBModelView',
|
||||
'Security') and
|
||||
perm.permission.name not in (
|
||||
'all_datasource_access',
|
||||
'can_add',
|
||||
'can_download',
|
||||
'can_delete',
|
||||
'can_edit',
|
||||
'can_save',
|
||||
'datasource_access',
|
||||
'muldelete',
|
||||
)):
|
||||
sm.add_permission_role(gamma, perm)
|
||||
if public_role_like_gamma:
|
||||
sm.add_permission_role(public_role, perm)
|
||||
@@ -222,6 +223,14 @@ def datetime_f(dttm):
|
||||
return "<nobr>{}</nobr>".format(dttm)
|
||||
|
||||
|
||||
def base_json_conv(obj):
|
||||
|
||||
if isinstance(obj, numpy.int64):
|
||||
return int(obj)
|
||||
elif isinstance(obj, set):
|
||||
return list(obj)
|
||||
|
||||
|
||||
def json_iso_dttm_ser(obj):
|
||||
"""
|
||||
json serializer that deals with dates
|
||||
@@ -230,10 +239,25 @@ def json_iso_dttm_ser(obj):
|
||||
>>> json.dumps({'dttm': dttm}, default=json_iso_dttm_ser)
|
||||
'{"dttm": "1970-01-01T00:00:00"}'
|
||||
"""
|
||||
val = base_json_conv(obj)
|
||||
if val is not None:
|
||||
return val
|
||||
if isinstance(obj, datetime):
|
||||
obj = obj.isoformat()
|
||||
elif isinstance(obj, numpy.int64):
|
||||
obj = int(obj)
|
||||
else:
|
||||
raise TypeError(
|
||||
"Unserializable object {} of type {}".format(obj, type(obj))
|
||||
)
|
||||
return obj
|
||||
|
||||
|
||||
def json_int_dttm_ser(obj):
|
||||
"""json serializer that deals with dates"""
|
||||
val = base_json_conv(obj)
|
||||
if val is not None:
|
||||
return val
|
||||
if isinstance(obj, datetime):
|
||||
obj = int(time.mktime(obj.timetuple())) * 1000
|
||||
else:
|
||||
raise TypeError(
|
||||
"Unserializable object {} of type {}".format(obj, type(obj))
|
||||
@@ -259,16 +283,12 @@ def readfile(filepath):
|
||||
return content
|
||||
|
||||
|
||||
def generic_find_constraint_name(table, columns, referenced):
|
||||
"""
|
||||
Utility to find a constraint name in alembic migrations
|
||||
"""
|
||||
engine = op.get_bind().engine
|
||||
m = sa.MetaData({})
|
||||
t = sa.Table(table, m, autoload=True, autoload_with=engine)
|
||||
def generic_find_constraint_name(table, columns, referenced, db):
|
||||
"""Utility to find a constraint name in alembic migrations"""
|
||||
t = sa.Table(table, db.metadata, autoload=True, autoload_with=db.engine)
|
||||
|
||||
for fk in t.foreign_key_constraints:
|
||||
if fk.referred_table.name == referenced and \
|
||||
set(fk.column_keys) == columns:
|
||||
if (
|
||||
fk.referred_table.name == referenced and
|
||||
set(fk.column_keys) == columns):
|
||||
return fk.name
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user