'Copy dashboard'

@api
@has_access_api
@expose(u'/copy_dash/<dashboard_id>/', methods=[u'GET', u'POST'])
def copy_dash(self, dashboard_id):

    session = db.session()
    data = json.loads(request.form.get(u'data'))
    dash = models.Dashboard()
    original_dash = session.query(models.Dashboard).filter_by(id=dashboard_id).first()
    dash.owners = ([g.user] if g.user else [])
    dash.dashboard_title = data[u'dashboard_title']
    dash.slices = original_dash.slices
    dash.params = original_dash.params
    self._set_dash_metadata(dash, data)
    session.add(dash)
    session.commit()
    dash_json = json.dumps(dash.data)
    session.close()
    return json_success(dash_json)
