def __init__(self, *args, **kwargs): from custom.bihar.reports.indicators.indicators import IndicatorConfig, INDICATOR_SETS from custom.bihar.reports.indicators.indicators import IndicatorDataProvider self.indicator_set = IndicatorConfig(INDICATOR_SETS).get_indicator_set(self.set_slug) super(MyPerformanceReport, self).__init__(*args, **kwargs) groups = groups_for_user(self.request.couch_user, self.domain) self.data_provider = IndicatorDataProvider( self.domain, self.indicator_set, groups, )
def get_all_calculations(owner_ids): from custom.bihar.reports.indicators.indicators import IndicatorConfig, INDICATOR_SETS config = IndicatorConfig(INDICATOR_SETS) for indicator_set in config.indicator_sets: for indicator in indicator_set.get_indicators(): slug = indicator.slug yield (indicator.name,) + get_calculation(owner_ids, slug)
def __call__(self, user, version, last_sync=None): if user.domain in hard_coded_domains: groups = filter(hard_coded_group_filter, Group.by_user(user)) if len(groups) == 1: data_provider = IndicatorDataProvider( domain=user.domain, indicator_set=IndicatorConfig(INDICATOR_SETS).get_indicator_set(hard_coded_indicators), groups=groups, ) return [self.get_fixture(user, data_provider)] return []
def __call__(self, restore_state): restore_user = restore_state.restore_user if restore_user.domain in hard_coded_domains: groups = filter(hard_coded_group_filter, restore_user.get_groups()) if len(groups) == 1: data_provider = IndicatorDataProvider( domain=restore_user.domain, indicator_set=IndicatorConfig(INDICATOR_SETS). get_indicator_set(hard_coded_indicators), groups=groups, ) return [self.get_fixture(restore_user.user_id, data_provider)] return []
def __call__(self, restore_user, version, last_sync=None, app=None): assert isinstance(restore_user, OTARestoreUser) if restore_user.domain in hard_coded_domains: groups = filter(hard_coded_group_filter, restore_user.get_groups()) if len(groups) == 1: data_provider = IndicatorDataProvider( domain=restore_user.domain, indicator_set=IndicatorConfig(INDICATOR_SETS). get_indicator_set(hard_coded_indicators), groups=groups, ) return [self.get_fixture(restore_user.user_id, data_provider)] return []
def generator(user, version, last_sync): if user.domain in hard_coded_domains: groups = filter(hard_coded_group_filter, Group.by_user(user)) if len(groups) == 1: data_provider = IndicatorDataProvider( domain=user.domain, indicator_set=IndicatorConfig(INDICATOR_SETS).get_indicator_set(hard_coded_indicators), groups=groups, ) fixture_provider = IndicatorFixtureProvider( hard_coded_fixture_id, user, data_provider ) return [fixture_provider.to_fixture()] return []
def indicator_config(self): from custom.bihar.reports.indicators.indicators import INDICATOR_SETS, IndicatorConfig return IndicatorConfig(INDICATOR_SETS)
def indicator_set(self): from custom.bihar.reports.indicators.indicators import INDICATOR_SETS, IndicatorConfig return IndicatorConfig(INDICATOR_SETS).get_indicator_set(self.indicator_set_slug)