Skip to content

Commit

Permalink
Enable list with checkboxes only on Table->Columns view (#1138)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 19, 2016
1 parent ca66ba4 commit 1c544c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions caravel/views.py
Expand Up @@ -21,6 +21,7 @@
from flask_appbuilder.actions import action
from flask_appbuilder.models.sqla.interface import SQLAInterface
from flask_appbuilder.security.decorators import has_access, has_access_api
from flask_appbuilder.widgets import ListWidget
from flask_babel import gettext as __
from flask_babel import lazy_gettext as _
from flask_appbuilder.models.sqla.filters import BaseFilter
Expand Down Expand Up @@ -62,6 +63,13 @@ def datasource_access(self, datasource):
self.can_access("datasource_access", datasource.perm))


class ListWidgetWithCheckboxes(ListWidget):
"""An alternative to list view that renders Boolean fields as checkboxes
Works in conjunction with the `checkbox` view."""
template = 'caravel/fab_overrides/list_with_checkboxes.html'


ALL_DATASOURCE_ACCESS_ERR = __(
"This endpoint requires the `all_datasource_access` permission")
DATASOURCE_MISSING_ERR = __("The datasource seems to have been deleted")
Expand Down Expand Up @@ -276,6 +284,7 @@ class CaravelModelView(ModelView):
class TableColumnInlineView(CompactCRUDMixin, CaravelModelView): # noqa
datamodel = SQLAInterface(models.TableColumn)
can_delete = False
list_widget = ListWidgetWithCheckboxes
edit_columns = [
'column_name', 'verbose_name', 'description', 'groupby', 'filterable',
'table', 'count_distinct', 'sum', 'min', 'max', 'expression',
Expand Down Expand Up @@ -853,6 +862,7 @@ class LogModelView(CaravelModelView):

class DruidDatasourceModelView(CaravelModelView, DeleteMixin): # noqa
datamodel = SQLAInterface(models.DruidDatasource)
list_widget = ListWidgetWithCheckboxes
list_columns = [
'datasource_link', 'cluster', 'changed_by_', 'changed_on_', 'offset']
order_columns = [
Expand Down

0 comments on commit 1c544c9

Please sign in to comment.