Skip to content

Commit

Permalink
+ button on Slice list view redirects to Table view with alert
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 5, 2016
1 parent 81de51b commit 3175882
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions caravel/templates/caravel/add_slice.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<script>
var msg = "Click on a table link to create a Slice";
window.location = "/r/msg/?url={{ '/tablemodelview/list/' }}&msg=" + msg;
</script>
7 changes: 7 additions & 0 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class DruidClusterModelView(CaravelModelView, DeleteMixin): # noqa

class SliceModelView(CaravelModelView, DeleteMixin): # noqa
datamodel = SQLAInterface(models.Slice)
add_template = "caravel/add_slice.html"
can_add = False
label_columns = {
'created_by_': 'Creator',
Expand Down Expand Up @@ -405,6 +406,12 @@ def shortner(self):
return("{request.headers[Host]}/r/{obj.id}".format(
request=request, obj=obj))

@expose("/msg/")
def msg(self):
"""Redirects to specified url while flash a message"""
flash(request.args.get("msg"), "info")
return redirect(request.args.get("url"))

appbuilder.add_view_no_menu(R)


Expand Down

0 comments on commit 3175882

Please sign in to comment.