Skip to content

Commit

Permalink
Multi delete action on datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jul 29, 2015
1 parent f07ea2b commit e8f480f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import config
from pydruid.client import doublesum
from wtforms.validators import ValidationError
from flask.ext.appbuilder.actions import action


def validate_json(form, field):
Expand All @@ -18,6 +19,13 @@ def validate_json(form, field):
except Exception as e:
raise ValidationError("Json isn't valid")

class DeleteMixin(object):
@action("muldelete", "Delete", "Delete all Really?", "fa-trash", single=False)
def muldelete(self, items):
self.datamodel.delete_all(items)
self.update_redirect()
return redirect(self.get_redirect())


class ColumnInlineView(CompactCRUDMixin, ModelView):
datamodel = SQLAInterface(models.Column)
Expand Down Expand Up @@ -54,7 +62,7 @@ class MetricInlineView(CompactCRUDMixin, ModelView):
appbuilder.add_view_no_menu(MetricInlineView)


class DatasourceModelView(ModelView):
class DatasourceModelView(ModelView, DeleteMixin):
datamodel = SQLAInterface(models.Datasource)
list_columns = ['datasource_link', 'owner', 'is_featured', 'is_hidden']
related_views = [ColumnInlineView, MetricInlineView]
Expand Down

0 comments on commit e8f480f

Please sign in to comment.