'Server side rendering for a dashboard'

@has_access
@expose(u'/dashboard/<dashboard_id>/')
def dashboard(self, dashboard_id):

    session = db.session()
    qry = session.query(models.Dashboard)
    if dashboard_id.isdigit():
        qry = qry.filter_by(id=int(dashboard_id))
    else:
        qry = qry.filter_by(slug=dashboard_id)
    dash = qry.one()
    datasources = set()
    for slc in dash.slices:
        datasource = slc.datasource
        if datasource:
            datasources.add(datasource)
    for datasource in datasources:
        if (datasource and (not self.datasource_access(datasource))):
            flash(__(get_datasource_access_error_msg(datasource.name)), u'danger')
            return redirect(u'superset/request_access/?dashboard_id={dash.id}&'.format(**locals()))
    @log_this
    def dashboard(**kwargs):
        pass
    dashboard(dashboard_id=dash.id)
    dash_edit_perm = check_ownership(dash, raise_if_false=False)
    dash_save_perm = (dash_edit_perm and self.can_access(u'can_save_dash', u'Superset'))
    dashboard_data = dash.data
    dashboard_data.update({u'standalone_mode': (request.args.get(u'standalone') == u'true'), u'dash_save_perm': dash_save_perm, u'dash_edit_perm': dash_edit_perm})
    bootstrap_data = {u'user_id': g.user.get_id(), u'dashboard_data': dashboard_data, u'datasources': {ds.uid: ds.data for ds in datasources}}
    return self.render_template(u'superset/dashboard.html', entry=u'dashboard', title=(u'[dashboard]    ' + dash.dashboard_title), bootstrap_data=json.dumps(bootstrap_data))
