'Overrides the dashboards using pickled instances from the file.'

@expose(u'/import_dashboards', methods=[u'GET', u'POST'])
@log_this
def import_dashboards(self):

    f = request.files.get(u'file')
    if ((request.method == u'POST') and f):
        current_tt = int(time.time())
        data = pickle.load(f)
        for table in data[u'datasources']:
            ds_class = ConnectorRegistry.sources.get(table.type)
            ds_class.import_obj(table, import_time=current_tt)
        db.session.commit()
        for dashboard in data[u'dashboards']:
            models.Dashboard.import_obj(dashboard, import_time=current_tt)
        db.session.commit()
        return redirect(u'/dashboardmodelview/list/')
    return self.render_template(u'superset/import_dashboards.html')
