Beispiel #1
0
def get_possible_reports(domain_name):
    from corehq.apps.reports.dispatcher import (ProjectReportDispatcher,
                                                CustomProjectReportDispatcher)
    from corehq.apps.data_interfaces.dispatcher import DataInterfaceDispatcher

    # todo: exports should be its own permission at some point?
    report_map = (ProjectReportDispatcher().get_reports(domain_name) +
                  CustomProjectReportDispatcher().get_reports(domain_name) +
                  DataInterfaceDispatcher().get_reports(domain_name))
    reports = []
    domain = Domain.get_by_name(domain_name)
    for heading, models in report_map:
        for model in models:
            if getattr(model, 'parent_report_class', None):
                report_to_check_if_viewable = model.parent_report_class
            else:
                report_to_check_if_viewable = model

            if report_to_check_if_viewable.show_in_navigation(
                    domain=domain_name, project=domain):
                reports.append({
                    'path': model.__module__ + '.' + model.__name__,
                    'name': model.name
                })

    for slug, name, is_visible in get_extra_permissions():
        if is_visible(domain):
            reports.append({'path': slug, 'name': name})
    return reports
Beispiel #2
0
def get_possible_reports(domain_name):
    from corehq.apps.reports.dispatcher import (ProjectReportDispatcher, CustomProjectReportDispatcher)

    # todo: exports should be its own permission at some point?
    report_map = (ProjectReportDispatcher().get_reports(domain_name) +
                  CustomProjectReportDispatcher().get_reports(domain_name))
    reports = []
    domain_obj = Domain.get_by_name(domain_name)
    for heading, models in report_map:
        for model in models:
            if getattr(model, 'parent_report_class', None):
                report_to_check_if_viewable = model.parent_report_class
            else:
                report_to_check_if_viewable = model

            if report_to_check_if_viewable.show_in_user_roles(domain=domain_name, project=domain_obj):
                path = model.__module__ + '.' + model.__name__
                reports.append({
                    'path': path,
                    'name': model.name,
                    'slug': path.replace('.', '_'),
                })

    for slug, name, is_visible in get_extra_permissions():
        if is_visible(domain_obj):
            reports.append({
                'path': slug,
                'name': name,
                'slug': slug.replace('.', '_'),
            })
    return reports
Beispiel #3
0
def get_possible_reports(domain):
    from corehq.apps.reports.dispatcher import (ProjectReportDispatcher,
                                                CustomProjectReportDispatcher)
    from corehq.apps.adm.dispatcher import ADMSectionDispatcher
    reports = []
    report_map = ProjectReportDispatcher().get_reports(domain) + \
                 CustomProjectReportDispatcher().get_reports(domain) +\
                 ADMSectionDispatcher().get_reports(domain)
    for heading, models in report_map:
        for model in models:
            reports.append({
                'path': model.__module__ + '.' + model.__name__,
                'name': model.name
            })
    return reports
Beispiel #4
0
    def sidebar_items(self):
        context = {
            'request': self._request,
            'domain': self.domain,
        }
        
        tools = [(_("Tools"), [
            {'title': _('My Saved Reports'),
             'url': reverse('saved_reports', args=[self.domain]),
             'icon': 'icon-tasks'}
        ])]

        project_reports = ProjectReportDispatcher.navigation_sections(
            context)
        custom_reports = CustomProjectReportDispatcher.navigation_sections(
            context)

        return tools + project_reports + custom_reports
Beispiel #5
0
    def sidebar_items(self):
        context = {
            'request': self._request,
            'domain': self.domain,
        }
        
        tools = [(_("Tools"), [
            {'title': _('My Saved Reports'),
             'url': reverse('saved_reports', args=[self.domain]),
             'icon': 'icon-tasks'}
        ])]

        project_reports = ProjectReportDispatcher.navigation_sections(
            context)
        custom_reports = CustomProjectReportDispatcher.navigation_sections(
            context)

        return tools + project_reports + custom_reports
Beispiel #6
0
def get_possible_reports(domain_name):
    from corehq.apps.reports.dispatcher import (ProjectReportDispatcher, CustomProjectReportDispatcher)
    from corehq.apps.data_interfaces.dispatcher import DataInterfaceDispatcher

    # todo: exports should be its own permission at some point?
    report_map = (ProjectReportDispatcher().get_reports(domain_name) +
                  CustomProjectReportDispatcher().get_reports(domain_name) +
                  DataInterfaceDispatcher().get_reports(domain_name))
    reports = []
    domain = Domain.get_by_name(domain_name)
    for heading, models in report_map:
        for model in models:
            if model.show_in_navigation(domain=domain_name, project=domain):
                reports.append({
                    'path': model.__module__ + '.' + model.__name__,
                    'name': model.name
                })
    return reports
Beispiel #7
0
    def sidebar_items(self):
        context = {"request": self._request, "domain": self.domain}

        tools = [
            (
                _("Tools"),
                [
                    {
                        "title": _("My Saved Reports"),
                        "url": reverse("saved_reports", args=[self.domain]),
                        "icon": "icon-tasks",
                    }
                ],
            )
        ]

        project_reports = ProjectReportDispatcher.navigation_sections(context)
        custom_reports = CustomProjectReportDispatcher.navigation_sections(context)

        return tools + project_reports + custom_reports
Beispiel #8
0
        'edit_scheduled_report', name="edit_scheduled_report"),
    url(r'^scheduled_report/(?P<scheduled_report_id>[\w-]+)/delete$',
        'delete_scheduled_report', name='delete_scheduled_report'),
    url(r'^send_test_scheduled_report/(?P<scheduled_report_id>[\w-]+)/$',
         'send_test_scheduled_report', name='send_test_scheduled_report'),
    url(r'^view_scheduled_report/(?P<scheduled_report_id>[\w_]+)/$',
        'view_scheduled_report', name='view_scheduled_report'),

    # Internal Use
    url(r"^export/forms/all/$", 'export_all_form_metadata', name="export_all_form_metadata"),
    url(r"^export/forms/all/async/$", 'export_all_form_metadata_async', name="export_all_form_metadata_async"),
    url(r'^download/cases/$', 'download_cases', name='download_cases'),

    url(r'^custom/', include(custom_report_urls)),
    url(r'^filters/', include(filter_urls)),
    ProjectReportDispatcher.url_pattern(),
)

report_urls = patterns('',
    BasicReportDispatcher.url_pattern(),
)

for module in get_installed_custom_modules():
    module_name = module.__name__.split('.')[-1]
    try:
        custom_report_urls += patterns('',
             (r"^%s/" % module_name, include('{0}.urls'.format(module.__name__))),
        )
    except ImproperlyConfigured:
        logging.info("Module %s does not provide urls" % module_name)
Beispiel #9
0
 def args_kwargs_from_context(cls, context):
     return ProjectReportDispatcher.args_kwargs_from_context(context)
Beispiel #10
0
    # Scheduled reports
    url(r'^scheduled_reports/(?P<scheduled_report_id>[\w-]+)?$',
        'edit_scheduled_report',
        name="edit_scheduled_report"),
    url(r'^scheduled_report/(?P<scheduled_report_id>[\w-]+)/delete$',
        'delete_scheduled_report',
        name='delete_scheduled_report'),
    url(r'^send_test_scheduled_report/(?P<scheduled_report_id>[\w-]+)/$',
        'send_test_scheduled_report',
        name='send_test_scheduled_report'),
    url(r'^view_scheduled_report/(?P<scheduled_report_id>[\w_]+)/$',
        'view_scheduled_report',
        name='view_scheduled_report'),

    # Internal Use
    url(r"^export/forms/all/$",
        'export_all_form_metadata',
        name="export_all_form_metadata"),
    url(r'^download/cases/$', 'download_cases', name='download_cases'),

    # TODO should this even be here?
    url(r'^phonelog/', include(phonelog_reports)),
    url(r'^custom/', include(custom_report_urls)),
    ProjectReportDispatcher.url_pattern(),
)

report_urls = patterns(
    '',
    BasicReportDispatcher.url_pattern(),
)
Beispiel #11
0
    url(r'^emaillist/$', 'emaillist', name="emailable_report_list"),
    url(r'^emailtest/(?P<report_slug>[\w_]+)/$', 'emailtest', name="emailable_report_test"),

    # Create and Manage Custom Exports
    url(r"^export/$", 'export_data'),
    url(r"^export/customize/$", 'custom_export', name="custom_export"),
    url(r"^export/custom/(?P<export_id>[\w\-]+)/edit/$", 'edit_custom_export', name="edit_custom_export"),
    url(r"^export/custom/(?P<export_id>[\w\-]+)/delete/$", 'delete_custom_export', name="delete_custom_export"),

    # Download Exports
    ## Custom
    url(r"^export/custom/(?P<export_id>[\w\-]+)/download/$", 'export_default_or_custom_data', name="export_custom_data"),
    ## Default
    url(r"^export/default/download/$", "export_default_or_custom_data", name="export_default_data"),
    ## Bulk
    url(r"^export/bulk/download/$", "export_default_or_custom_data", name="export_bulk_download", kwargs=dict(bulk_export=True)),
    ## saved
    url(r"^export/saved/download/(?P<export_id>[\w\-]+)/$", "hq_download_saved_export", name="hq_download_saved_export"),

    # Internal Use
    url(r"^export/forms/all/$", 'export_all_form_metadata', name="export_all_form_metadata"),
    url(r'^download/cases/$', 'download_cases', name='download_cases'),

    # TODO should this even be here?
    url(r'^phonelog/', include(phonelog_reports)),

    url(r'^custom/', include(custom_report_urls)),
    url(ProjectReportDispatcher.pattern(), ProjectReportDispatcher.as_view(),
        name=ProjectReportDispatcher.name()
    )
)