Skip to content

Commit

Permalink
More translation instrumentation and some french to test
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed May 21, 2016
1 parent c53874c commit f50de06
Show file tree
Hide file tree
Showing 13 changed files with 2,000 additions and 177 deletions.
388 changes: 362 additions & 26 deletions babel/messages.pot

Large diffs are not rendered by default.

Binary file added caravel/assets/images/druid_agg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added caravel/translations/es/LC_MESSAGES/messages.mo
Binary file not shown.
388 changes: 365 additions & 23 deletions caravel/translations/es/LC_MESSAGES/messages.po

Large diffs are not rendered by default.

Binary file modified caravel/translations/fr/LC_MESSAGES/messages.mo
Binary file not shown.
396 changes: 369 additions & 27 deletions caravel/translations/fr/LC_MESSAGES/messages.po

Large diffs are not rendered by default.

Binary file modified caravel/translations/it/LC_MESSAGES/messages.mo
Binary file not shown.
418 changes: 381 additions & 37 deletions caravel/translations/it/LC_MESSAGES/messages.po

Large diffs are not rendered by default.

Binary file modified caravel/translations/zh/LC_MESSAGES/messages.mo
Binary file not shown.
397 changes: 370 additions & 27 deletions caravel/translations/zh/LC_MESSAGES/messages.po

Large diffs are not rendered by default.

137 changes: 126 additions & 11 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from flask.ext.appbuilder.actions import action
from flask.ext.appbuilder.models.sqla.interface import SQLAInterface
from flask.ext.appbuilder.security.decorators import has_access
from flask.ext.babelpkg import gettext as _
from flask.ext.babelpkg import gettext as __
from flask.ext.babelpkg import lazy_gettext as _
from flask_appbuilder.models.sqla.filters import BaseFilter

from pydruid.client import doublesum
Expand Down Expand Up @@ -128,6 +129,20 @@ class TableColumnInlineView(CompactCRUDMixin, CaravelModelView): # noqa
"a valid SQL expression as supported by the underlying backend. "
"Example: `substr(name, 1, 1)`", True),
}
label_columns = {
'column_name': _("Column"),
'verbose_name': _("Verbose Name"),
'description': _("Description"),
'groupby': _("Groupable"),
'filterable': _("Filterable"),
'table': _("Table"),
'count_distinct': _("Count Distinct"),
'sum': _("Sum"),
'min': _("Min"),
'max': _("Max"),
'expression': _("Expression"),
'is_dttm': _("Is temporal"),
}
appbuilder.add_view_no_menu(TableColumnInlineView)


Expand All @@ -142,6 +157,17 @@ class DruidColumnInlineView(CompactCRUDMixin, CaravelModelView): # noqa
'sum', 'min', 'max']
can_delete = False
page_size = 500
label_columns = {
'column_name': _("Column"),
'type': _("Type"),
'datasource': _("Datasource"),
'groupby': _("Groupable"),
'filterable': _("Filterable"),
'count_distinct': _("Count Distinct"),
'sum': _("Sum"),
'min': _("Min"),
'max': _("Max"),
}

def post_update(self, col):
col.generate_metrics()
Expand All @@ -162,6 +188,14 @@ class SqlMetricInlineView(CompactCRUDMixin, CaravelModelView): # noqa
}
add_columns = edit_columns
page_size = 500
label_columns = {
'metric_name': _("Metric"),
'description': _("Description"),
'verbose_name': _("Verbose Name"),
'metric_type': _("Type"),
'expression': _("SQL Expression"),
'table': _("Table"),
}
appbuilder.add_view_no_menu(SqlMetricInlineView)


Expand All @@ -183,6 +217,14 @@ class DruidMetricInlineView(CompactCRUDMixin, CaravelModelView): # noqa
"(http://druid.io/docs/latest/querying/post-aggregations.html)",
True),
}
label_columns = {
'metric_name': _("Metric"),
'description': _("Description"),
'verbose_name': _("Verbose Name"),
'metric_type': _("Type"),
'json': _("JSON"),
'datasource': _("Druid Datasource"),
}
appbuilder.add_view_no_menu(DruidMetricInlineView)


Expand Down Expand Up @@ -211,6 +253,15 @@ class DatabaseView(CaravelModelView, DeleteMixin): # noqa
"(http://docs.sqlalchemy.org/en/rel_1_0/core/metadata.html"
"#sqlalchemy.schema.MetaData) call. ", True),
}
label_columns = {
'database_name': _("Database"),
'sql_link': _("SQL link"),
'creator': _("Creator"),
'changed_on_': _("Last Changed"),
'sqlalchemy_uri': _("SQLAlchemy URI"),
'cache_timeout': _("Cache Timeout"),
'extra': _("Extra"),
}

def pre_add(self, db):
conn = sqla.engine.url.make_url(db.sqlalchemy_uri)
Expand Down Expand Up @@ -253,6 +304,18 @@ class TableModelView(CaravelModelView, DeleteMixin): # noqa
"Supports <a href='https://daringfireball.net/projects/markdown/'>"
"markdown</a>"),
}
label_columns = {
'table_link': _("Table"),
'changed_by_': _("Changed By"),
'database': _("Database"),
'changed_on_': _("Last Changed"),
'sql_link': _("SQL Editor"),
'is_featured': _("Is Featured"),
'schema': _("Schema"),
'default_endpoint': _("Default Endpoint"),
'offset': _("Offset"),
'cache_timeout': _("Cache Timeout"),
}

def post_add(self, table):
try:
Expand All @@ -270,7 +333,7 @@ def post_update(self, table):

appbuilder.add_view(
TableModelView,
_("Tables"),
__("Tables"),
category=_("Sources"),
icon='fa-table',)

Expand All @@ -287,12 +350,21 @@ class DruidClusterModelView(CaravelModelView, DeleteMixin): # noqa
]
edit_columns = add_columns
list_columns = ['cluster_name', 'metadata_last_refreshed']
label_columns = {
'cluster_name': _("Cluster"),
'coordinator_host': _("Coordinator Host"),
'coordinator_port': _("Coordinator Port"),
'coordinator_endpoint': _("Coordinator Endpoint"),
'broker_host': _("Broker Host"),
'broker_port': _("Borker Port"),
'broker_endpoint': _("Broker Endpoint"),
}


if config['DRUID_IS_ACTIVE']:
appbuilder.add_view(
DruidClusterModelView,
_("Druid Clusters"),
__("Druid Clusters"),
icon="fa-cubes",
category=_("Sources"),
category_icon='fa-database',)
Expand Down Expand Up @@ -320,10 +392,24 @@ class SliceModelView(CaravelModelView, DeleteMixin): # noqa
"markdown</a>"),
}
base_filters = [['id', FilterSlice, lambda: []]]
label_columns = {
'cache_timeout': _("Cache Timeout"),
'creator': _("Creator"),
'dashboards': _("Dashboards"),
'datasource_link': _("Datasource"),
'description': _("Description"),
'modified': _("Last Modified"),
'owners': _("Owners"),
'params': _("Parameters"),
'slice_link': _("Slice"),
'slice_name': _("Name"),
'table': _("Table"),
'viz_type': _("Visualization Type"),
}

appbuilder.add_view(
SliceModelView,
_("Slices"),
__("Slices"),
icon="fa-bar-chart",
category="",
category_icon='',)
Expand All @@ -335,8 +421,9 @@ class SliceAsync(SliceModelView): # noqa
'creator', 'modified', 'icons']
label_columns = {
'icons': ' ',
'viz_type': 'Type',
'slice_link': 'Slice',
'viz_type': _('Type'),
'slice_link': _('Slice'),
'viz_type': _('Visualization Type'),
}

appbuilder.add_view_no_menu(SliceAsync)
Expand All @@ -360,9 +447,21 @@ class DashboardModelView(CaravelModelView, DeleteMixin): # noqa
"The css for individual dashboards can be altered here, or "
"in the dashboard view where changes are immediately "
"visible"),
'slug': "To get a readable URL for your dashboard",
'slug': _("To get a readable URL for your dashboard"),
}
base_filters = [['slice', FilterDashboard, lambda: []]]
label_columns = {
'dashboard_link': _("Dashboard"),
'dashboard_title': _("Title"),
'slug': _("Slug"),
'slices': _("Slices"),
'owners': _("Owners"),
'creator': _("Creator"),
'modified': _("Modified"),
'position_json': _("Position JSON"),
'css': _("CSS"),
'json_metadata': _("JSON Metadata"),
}

def pre_add(self, obj):
obj.slug = obj.slug.strip() or None
Expand All @@ -379,7 +478,6 @@ def pre_update(self, obj):
"Dashboards",
label=_("Dashboards"),
icon="fa-dashboard",

category="",
category_icon='',)

Expand All @@ -398,6 +496,12 @@ class LogModelView(CaravelModelView):
list_columns = ('user', 'action', 'dttm')
edit_columns = ('user', 'action', 'dttm', 'json')
base_order = ('dttm', 'desc')
label_columns = {
'user': _("User"),
'action': _("Action"),
'dttm': _("dttm"),
'json': _("JSON"),
}

appbuilder.add_view(
LogModelView,
Expand All @@ -420,11 +524,22 @@ class DruidDatasourceModelView(CaravelModelView, DeleteMixin): # noqa
page_size = 500
base_order = ('datasource_name', 'asc')
description_columns = {
'offset': "Timezone offset (in hours) for this datasource",
'offset': _("Timezone offset (in hours) for this datasource"),
'description': Markup(
"Supports <a href='"
"https://daringfireball.net/projects/markdown/'>markdown</a>"),
}
label_columns = {
'datasource_name': _("Data Source"),
'cluster': _("Cluster"),
'description': _("Description"),
'owner': _("Owner"),
'is_featured': _("Is Featured"),
'is_hidden': _("Is Hidden"),
'default_endpoint': _("Default Endpoint"),
'offset': _("Time Offset"),
'cache_timeout': _("Cache Timeout"),
}

def post_add(self, datasource):
datasource.generate_metrics()
Expand Down Expand Up @@ -521,15 +636,15 @@ def explore(self, datasource_type, datasource_id):
.first()
)
if not datasource:
flash(_("The datasource seems to have been deleted"), "alert")
flash(__("The datasource seems to have been deleted"), "alert")
return redirect(error_redirect)

all_datasource_access = self.appbuilder.sm.has_access(
'all_datasource_access', 'all_datasource_access')
datasource_access = self.appbuilder.sm.has_access(
'datasource_access', datasource.perm)
if not (all_datasource_access or datasource_access):
flash(_("You don't seem to have access to this datasource"), "danger")
flash(__("You don't seem to have access to this datasource"), "danger")
return redirect(error_redirect)

action = request.args.get('action')
Expand Down
Loading

0 comments on commit f50de06

Please sign in to comment.