Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(IndicatorSummaryReport, self).__init__(*args, **kwargs)
     from custom.bihar.reports.indicators.indicators import IndicatorDataProvider
     self.data_provider = IndicatorDataProvider(
         self.domain,
         self.indicator_set,
         [self.group],
     )
Ejemplo n.º 2
0
 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,
     )
Ejemplo n.º 3
0
class IndicatorSummaryReport(GroupReferenceMixIn, BiharSummaryReport,
                             IndicatorSetMixIn):

    name = ugettext_noop("Indicators")
    slug = "indicatorsummary"
    description = "Indicator details report"
    base_template_mobile = "bihar/indicator_summary.html"
    is_cacheable = True

    def __init__(self, *args, **kwargs):
        super(IndicatorSummaryReport, self).__init__(*args, **kwargs)
        from custom.bihar.reports.indicators.indicators import IndicatorDataProvider
        self.data_provider = IndicatorDataProvider(
            self.domain,
            self.indicator_set,
            [self.group],
        )

    @property
    def rendered_report_title(self):
        return _(self.indicator_set.name)

    @property
    def _headers(self):
        return {
            'supervisor': [_("Team Name")] +
            [_(i.name) for i in self.data_provider.summary_indicators],
            'manager': [_("Subcentre")] +
            [_(i.name) for i in self.data_provider.summary_indicators],
        }

    @property
    @memoized
    def data(self):
        def _nav_link(indicator):
            params = copy(self.request_params)
            params['indicator'] = indicator.slug
            del params['next_report']
            return format_html(
                u'{chart}<a href="{next}">{val}</a>',
                val=self.data_provider.get_indicator_value(indicator),
                chart=self.data_provider.get_chart(indicator),
                next=url_and_params(
                    IndicatorClientList.get_url(self.domain,
                                                render_as=self.render_next),
                    params,
                ))

        return [self.group_display] + \
               [_nav_link(i) for i in self.data_provider.summary_indicators]
Ejemplo n.º 4
0
class IndicatorSummaryReport(GroupReferenceMixIn, BiharSummaryReport,
                             IndicatorSetMixIn):
    
    name = ugettext_noop("Indicators")
    slug = "indicatorsummary"
    description = "Indicator details report"
    base_template_mobile = "bihar/indicator_summary.html"
    is_cacheable = True

    def __init__(self, *args, **kwargs):
        super(IndicatorSummaryReport, self).__init__(*args, **kwargs)
        from custom.bihar.reports.indicators.indicators import IndicatorDataProvider
        self.data_provider = IndicatorDataProvider(
            self.domain, self.indicator_set, [self.group],
        )

    @property
    def rendered_report_title(self):
        return _(self.indicator_set.name)

    @property
    def _headers(self):
        return {
            'supervisor': [_("Team Name")] + [_(i.name) for i in self.data_provider.summary_indicators],
            'manager': [_("Subcentre")] + [_(i.name) for i in self.data_provider.summary_indicators],
        }
    
    @property
    @memoized
    def data(self):
        def _nav_link(indicator):
            params = copy(self.request_params)
            params['indicator'] = indicator.slug
            del params['next_report']
            return format_html(u'{chart}<a href="{next}">{val}</a>',
                val=self.data_provider.get_indicator_value(indicator),
                chart=self.data_provider.get_chart(indicator),
                next=url_and_params(
                    IndicatorClientList.get_url(self.domain,
                                                render_as=self.render_next),
                    params,
            ))

        return [self.group_display] + \
               [_nav_link(i) for i in self.data_provider.summary_indicators]
Ejemplo n.º 5
0
 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,
     )
Ejemplo n.º 6
0
class MyPerformanceReport(BiharSummaryReport):
    name = ugettext_noop('My Performance')
    slug = 'myperformance'
    description = "My performance indicators report"
    set_slug = 'homevisit'  # hard coded to homevisit indicators
    base_template_mobile = "bihar/indicator_summary.html"

    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,
        )

    @property
    def _headers(self):
        return [_(i.name) for i in self.data_provider.summary_indicators]

    @property
    @memoized
    def data(self):
        def _nav_link(indicator):
            params = copy(self.request_params)
            params["indicators"] = self.set_slug
            params['indicator'] = indicator.slug
            return format_html(
                u'{chart}<a href="{next}">{val}</a>',
                val=self.data_provider.get_indicator_value(indicator),
                chart=self.data_provider.get_chart(indicator),
                next=url_and_params(
                    MyPerformanceList.get_url(domain=self.domain,
                                              render_as=self.render_next),
                    params,
                ))

        return [_nav_link(i) for i in self.data_provider.summary_indicators]
Ejemplo n.º 7
0
 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 []
Ejemplo n.º 8
0
class MyPerformanceReport(BiharSummaryReport):
    name = ugettext_noop('My Performance')
    slug = 'myperformance'
    description = "My performance indicators report"
    set_slug = 'homevisit'  # hard coded to homevisit indicators
    base_template_mobile = "bihar/indicator_summary.html"

    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,
        )

    @property
    def _headers(self):
        return [_(i.name) for i in self.data_provider.summary_indicators]

    @property
    @memoized
    def data(self):
        def _nav_link(indicator):
            params = copy(self.request_params)
            params["indicators"] = self.set_slug
            params['indicator'] = indicator.slug
            return format_html(u'{chart}<a href="{next}">{val}</a>',
                val=self.data_provider.get_indicator_value(indicator),
                chart=self.data_provider.get_chart(indicator),
                next=url_and_params(
                    MyPerformanceList.get_url(domain=self.domain,
                                              render_as=self.render_next),
                    params,
                )
            )

        return [_nav_link(i) for i in self.data_provider.summary_indicators]
Ejemplo n.º 9
0
    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 []
Ejemplo n.º 10
0
    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 []
Ejemplo n.º 11
0
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 []
Ejemplo n.º 12
0
 def __init__(self, *args, **kwargs):
     super(IndicatorSummaryReport, self).__init__(*args, **kwargs)
     from custom.bihar.reports.indicators.indicators import IndicatorDataProvider
     self.data_provider = IndicatorDataProvider(
         self.domain, self.indicator_set, [self.group],
     )