def create_missing_metrics_perm(view_menu_set):
 logging.info(u'Creating missing metrics permissions')
 metrics = []
 for model in [models.SqlMetric, models.DruidMetric]:
  metrics += list(db.session.query(model).all())
 for metric in metrics:
  if (metric.is_restricted and metric.perm and (metric.perm not in view_menu_set)):
   merge_perm(sm, u'metric_access', metric.perm)

def create_missing_metrics_perm ( view_menu_set ) : logging . info ( u'Creating missing metrics permissions' ) metrics = [ ] for model in [ models . SqlMetric , models . DruidMetric ] : metrics += list ( db . session . query ( model ) . all ( ) ) for metric in metrics : if ( metric . is_restricted and metric . perm and ( metric . perm not in view_menu_set ) ) : merge_perm ( sm , u'metric_access' , metric . perm )
create permissions for restricted metrics .