Skip to content

Commit

Permalink
fix function name and test user permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
sidgupta committed Apr 9, 2016
1 parent b828f4b commit 5f4c5aa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def explore(self, datasource_type, datasource_id):

action = request.args.get('action')
if action in ('save', 'overwrite'):
return self.saveoroverwriteslice(request.args, slc)
return self.save_or_overwrite_slice(request.args, slc)

viz_type = request.args.get("viz_type")
if not viz_type and datasource.default_endpoint:
Expand Down Expand Up @@ -522,7 +522,7 @@ def explore(self, datasource_type, datasource_id):
mimetype="application/json")
return resp

def saveoroverwriteslice(self, args, slc):
def save_or_overwrite_slice(self, args, slc):
"""Saves (inserts or overwrite a slice) """
slice_name = args.get('slice_name')
action = args.get('action')
Expand Down Expand Up @@ -557,22 +557,20 @@ def saveoroverwriteslice(self, args, slc):
slc.datasource_type = datasource_type
slc.slice_name = slice_name

if action == 'save':
if action == 'save' and self.appbuilder.sm.has_access('can_add', 'SliceModelView'):
self.save_slice(slc)
elif action == 'overwrite':
elif action == 'overwrite' and self.appbuilder.sm.has_access('can_edit', 'SliceModelView'):
self.overwrite_slice(slc)

return redirect(slc.slice_url)

@has_access
def save_slice(self, slc):
session = db.session()
msg = "Slice [{}] has been saved".format(slc.slice_name)
session.add(slc)
session.commit()
flash(msg, "info")

@has_access
def overwrite_slice(self, slc):
session = db.session()
msg = "Slice [{}] has been overwritten".format(slc.slice_name)
Expand Down

0 comments on commit 5f4c5aa

Please sign in to comment.