Esempio n. 1
0
 def tiles(self):
     return [
         TileConfiguration(
             title=_('Chart'),
             slug='chart',
             icon='fcc fcc-piegraph-report',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'chart']),
             help_text=_(
                 'A bar graph or a pie chart to show data from your cases or forms.'
                 ' You choose the property to graph.'),
         ),
         TileConfiguration(
             title=_('Form or Case List'),
             slug='form-or-case-list',
             icon='fcc fcc-form-report',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'list']),
             help_text=_('A list of cases or form submissions.'
                         ' You choose which properties will be columns.'),
         ),
         TileConfiguration(
             title=_('Worker Report'),
             slug='worker-report',
             icon='fcc fcc-user-report',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'worker']),
             help_text=_(
                 'A table of your mobile workers.'
                 ' You choose which properties will be the columns.'),
         ),
         TileConfiguration(
             title=_('Data Table'),
             slug='data-table',
             icon='fcc fcc-datatable-report',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'table']),
             help_text=_(
                 'A table of aggregated data from form submissions or case properties.'
                 ' You choose the columns and rows.'),
         ),
     ]
Esempio n. 2
0
def _get_default_tile_configurations():
    can_edit_data = lambda request: (request.couch_user.can_edit_data()
                                     or request.couch_user.can_access_any_exports())
    can_edit_apps = lambda request: (request.couch_user.is_web_user()
                                     or request.couch_user.can_edit_apps())
    can_view_reports = lambda request: user_can_view_reports(request.project, request.couch_user)
    can_edit_users = lambda request: (request.couch_user.can_edit_commcare_users()
                                      or request.couch_user.can_edit_web_users())

    def can_edit_locations_not_users(request):
        if not has_privilege(request, privileges.LOCATIONS):
            return False
        user = request.couch_user
        return not can_edit_users(request) and (
            user.can_edit_locations() or user_can_edit_location_types(user, request.project)
        )

    can_view_commtrack_setup = lambda request: (request.project.commtrack_enabled)

    can_view_exchange = lambda request: can_edit_apps(request) and not settings.ENTERPRISE_MODE

    def _can_access_sms(request):
        return has_privilege(request, privileges.OUTBOUND_SMS)

    def _can_access_reminders(request):
        return has_privilege(request, privileges.REMINDERS_FRAMEWORK)

    can_use_messaging = lambda request: (
        (_can_access_reminders(request) or _can_access_sms(request))
        and not request.couch_user.is_commcare_user()
        and request.couch_user.can_edit_data()
    )

    is_billing_admin = lambda request: request.couch_user.can_edit_billing()

    return [
        TileConfiguration(
            title=_('Applications'),
            slug='applications',
            icon='fcc fcc-applications',
            context_processor_class=AppsPaginatedContext,
            visibility_check=can_edit_apps,
            urlname='default_new_app' if APP_MANAGER_V2.enabled_for_request else 'default_app',
            help_text=_('Build, update, and deploy applications'),
        ),
        TileConfiguration(
            title=_('Form Submissions'),
            slug='graph',
            icon='fcc fcc-reports',
            context_processor_class=DatadogContext,
            visibility_check=DASHBOARD_GRAPHS.enabled_for_request,
            help_text=_("Form submissions for this domain over the last 7 days"),
        ),
        TileConfiguration(
            title=_('Reports'),
            slug='reports',
            icon='fcc fcc-reports',
            context_processor_class=ReportsPaginatedContext,
            urlname='reports_home',
            visibility_check=can_view_reports,
            help_text=_('View worker monitoring reports and inspect '
                        'project data'),
        ),
        TileConfiguration(
            title=_('{cc_name} Supply Setup').format(cc_name=settings.COMMCARE_NAME),
            slug='commtrack_setup',
            icon='fcc fcc-commtrack',
            context_processor_class=IconContext,
            urlname='default_commtrack_setup',
            visibility_check=can_view_commtrack_setup,
            help_text=_("Update {cc_name} Supply Settings").format(cc_name=settings.COMMCARE_NAME),
        ),
        TileConfiguration(
            title=_('Data'),
            slug='data',
            icon='fcc fcc-data',
            context_processor_class=DataPaginatedContext,
            urlname="data_interfaces_default",
            visibility_check=can_edit_data,
            help_text=_('Export and manage data'),
        ),
        TileConfiguration(
            title=_('Users'),
            slug='users',
            icon='fcc fcc-users',
            context_processor_class=IconContext,
            urlname=DefaultProjectUserSettingsView.urlname,
            visibility_check=can_edit_users,
            help_text=_('Manage accounts for mobile workers '
                        'and CommCareHQ users'),
        ),
        TileConfiguration(
            title=_('Organization'),
            slug='locations',
            icon='fcc fcc-users',
            context_processor_class=IconContext,
            urlname='default_locations_view',
            visibility_check=can_edit_locations_not_users,
            help_text=_('Manage the Organization Hierarchy'),
        ),
        TileConfiguration(
            title=_('Messaging'),
            slug='messaging',
            icon='fcc fcc-messaging',
            context_processor_class=IconContext,
            urlname='sms_default',
            visibility_check=can_use_messaging,
            help_text=_('Configure and schedule SMS messages and keywords'),
        ),
        TileConfiguration(
            title=_('Exchange'),
            slug='exchange',
            icon='fcc fcc-exchange',
            context_processor_class=IconContext,
            urlname='appstore',
            visibility_check=can_view_exchange,
            url_generator=lambda urlname, req: reverse(urlname),
            help_text=_('Download and share CommCare applications with '
                        'other users around the world'),
        ),
        TileConfiguration(
            title=_('Settings'),
            slug='settings',
            icon='fcc fcc-settings',
            context_processor_class=IconContext,
            urlname=DefaultProjectSettingsView.urlname,
            visibility_check=is_billing_admin,
            help_text=_('Set project-wide settings and manage subscriptions'),
        ),
        TileConfiguration(
            title=_('Help Site'),
            slug='help',
            icon='fcc fcc-help',
            context_processor_class=IconContext,
            url='http://help.commcarehq.org/',
            help_text=_("Visit CommCare's knowledge base"),
        ),
    ]
Esempio n. 3
0
def _get_default_tile_configurations():
    can_edit_data = lambda request: (request.couch_user.can_edit_data(
    ) or request.couch_user.can_access_any_exports())
    can_edit_apps = lambda request: (request.couch_user.is_web_user() or
                                     request.couch_user.can_edit_apps())
    can_view_reports = lambda request: user_can_view_reports(
        request.project, request.couch_user)
    can_edit_users = lambda request: (
        request.couch_user.can_edit_commcare_users(
        ) or request.couch_user.can_edit_web_users())

    can_view_commtrack_setup = lambda request: (request.project.
                                                commtrack_enabled)

    can_view_exchange = lambda request: can_edit_apps(
        request) and not settings.ENTERPRISE_MODE

    def _can_access_sms(request):
        return has_privilege(request, privileges.OUTBOUND_SMS)

    def _can_access_reminders(request):
        return has_privilege(request, privileges.REMINDERS_FRAMEWORK)

    can_use_messaging = lambda request: (
        (_can_access_reminders(request) or
         _can_access_sms(request)) and not request.couch_user.is_commcare_user(
         ) and request.couch_user.can_edit_data())

    is_billing_admin = lambda request: request.couch_user.can_edit_billing()

    return [
        TileConfiguration(
            title=_('Applications'),
            slug='applications',
            icon='fcc fcc-applications',
            context_processor_class=AppsPaginatedContext,
            visibility_check=can_edit_apps,
            urlname='default_app',
            help_text=_('Build, update, and deploy applications'),
        ),
        TileConfiguration(
            title=_('Reports'),
            slug='reports',
            icon='fcc fcc-reports',
            context_processor_class=ReportsPaginatedContext,
            urlname='reports_home',
            visibility_check=can_view_reports,
            help_text=_('View worker monitoring reports and inspect '
                        'project data'),
        ),
        TileConfiguration(
            title=_('CommCare Supply Setup'),
            slug='commtrack_setup',
            icon='fcc fcc-commtrack',
            context_processor_class=IconContext,
            urlname='default_commtrack_setup',
            visibility_check=can_view_commtrack_setup,
            help_text=_("Update CommCare Supply Settings"),
        ),
        TileConfiguration(
            title=_('Data'),
            slug='data',
            icon='fcc fcc-data',
            context_processor_class=DataPaginatedContext,
            urlname="data_interfaces_default",
            visibility_check=can_edit_data,
            help_text=_('Export and manage data'),
        ),
        TileConfiguration(
            title=_('Users'),
            slug='users',
            icon='fcc fcc-users',
            context_processor_class=IconContext,
            urlname=DefaultProjectUserSettingsView.urlname,
            visibility_check=can_edit_users,
            help_text=_('Manage accounts for mobile workers '
                        'and CommCareHQ users'),
        ),
        TileConfiguration(
            title=_('Messaging'),
            slug='messaging',
            icon='fcc fcc-messaging',
            context_processor_class=IconContext,
            urlname='sms_default',
            visibility_check=can_use_messaging,
            help_text=_('Configure and schedule SMS messages and keywords'),
        ),
        TileConfiguration(
            title=_('Exchange'),
            slug='exchange',
            icon='fcc fcc-exchange',
            context_processor_class=IconContext,
            urlname='appstore',
            visibility_check=can_view_exchange,
            url_generator=lambda urlname, req: reverse(urlname),
            help_text=_('Download and share CommCare applications with '
                        'other users around the world'),
        ),
        TileConfiguration(
            title=_('Settings'),
            slug='settings',
            icon='fcc fcc-settings',
            context_processor_class=IconContext,
            urlname=DefaultProjectSettingsView.urlname,
            visibility_check=is_billing_admin,
            help_text=_('Set project-wide settings and manage subscriptions'),
        ),
        TileConfiguration(
            title=_('Help Site'),
            slug='help',
            icon='fcc fcc-help',
            context_processor_class=IconContext,
            url='http://help.commcarehq.org/',
            help_text=_("Visit CommCare's knowledge base"),
        ),
    ]
Esempio n. 4
0
def _get_default_tile_configurations():
    can_edit_data = lambda request: (request.couch_user.can_edit_data() or
                                     request.couch_user.can_export_data())
    can_edit_apps = lambda request: (request.couch_user.is_web_user() or
                                     request.couch_user.can_edit_apps())
    can_view_reports = lambda request: (request.couch_user.can_view_reports(
    ) or request.couch_user.get_viewable_reports())
    can_edit_users = lambda request: (
        request.couch_user.can_edit_commcare_users(
        ) or request.couch_user.can_edit_web_users())

    def _can_access_sms(request):
        try:
            ensure_request_has_privilege(request, privileges.OUTBOUND_SMS)
        except PermissionDenied:
            return False
        return True

    def _can_access_reminders(request):
        try:
            ensure_request_has_privilege(request,
                                         privileges.REMINDERS_FRAMEWORK)
            return True
        except PermissionDenied:
            return False

    can_use_messaging = lambda request: (
        (_can_access_reminders or _can_access_sms) and not request.couch_user.
        is_commcare_user() and request.couch_user.can_edit_data())

    is_domain_admin = lambda request: request.couch_user.is_domain_admin(
        request.domain)

    return [
        TileConfiguration(
            title=_('Applications'),
            slug='applications',
            icon='dashboard-icon-applications',
            context_processor_class=AppsPaginatedContext,
            visibility_check=can_edit_apps,
        ),
        TileConfiguration(
            title=_('Reports'),
            slug='reports',
            icon='dashboard-icon-report',
            context_processor_class=ReportsPaginatedContext,
            urlname='reports_home',
            visibility_check=can_view_reports,
        ),
        TileConfiguration(
            title=_('Data'),
            slug='data',
            icon='dashboard-icon-data',
            context_processor_class=IconContext,
            urlname='data_interfaces_default',
            visibility_check=can_edit_data,
        ),
        TileConfiguration(
            title=_('Users'),
            slug='users',
            icon='dashboard-icon-users',
            context_processor_class=IconContext,
            urlname=DefaultProjectUserSettingsView.urlname,
            visibility_check=can_edit_users,
        ),
        TileConfiguration(
            title=_('Messaging'),
            slug='messaging',
            icon='dashboard-icon-messaging',
            context_processor_class=IconContext,
            urlname='sms_default',
            visibility_check=can_use_messaging,
        ),
        TileConfiguration(
            title=_('Exchange'),
            slug='exchange',
            icon='dashboard-icon-exchange',
            context_processor_class=IconContext,
            urlname='appstore',
            visibility_check=can_edit_apps,
            url_generator=lambda urlname, req: reverse(urlname),
        ),
        TileConfiguration(
            title=_('Settings'),
            slug='settings',
            icon='dashboard-icon-settings',
            context_processor_class=IconContext,
            urlname=DefaultProjectSettingsView.urlname,
            visibility_check=is_domain_admin,
        ),
        TileConfiguration(
            title=_('Help Site'),
            slug='help',
            icon='dashboard-icon-help',
            context_processor_class=IconContext,
            url='http://help.commcarehq.org/',
        ),
    ]
Esempio n. 5
0
 def tiles(self):
     clicked_tile = "Clicked on Report Builder Tile"
     tiles = [
         TileConfiguration(
             title=_('Chart'),
             slug='chart',
             analytics_usage_label="Chart",
             analytics_workflow_labels=[
                 clicked_tile,
                 "Clicked Chart Tile",
             ],
             icon='fcc fcc-piegraph-report',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'chart']),
             help_text=_(
                 'A bar graph or a pie chart to show data from your cases or forms.'
                 ' You choose the property to graph.'),
         ),
         TileConfiguration(
             title=_('Form or Case List'),
             slug='form-or-case-list',
             analytics_usage_label="List",
             analytics_workflow_labels=[
                 clicked_tile, "Clicked Form or Case List Tile"
             ],
             icon='fcc fcc-form-report',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'list']),
             help_text=_('A list of cases or form submissions.'
                         ' You choose which properties will be columns.'),
         ),
         TileConfiguration(
             title=_('Worker Report'),
             slug='worker-report',
             analytics_usage_label="Worker",
             analytics_workflow_labels=[
                 clicked_tile,
                 "Clicked Worker Report Tile",
             ],
             icon='fcc fcc-user-report',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'worker']),
             help_text=_(
                 'A table of your mobile workers.'
                 ' You choose which properties will be the columns.'),
         ),
         TileConfiguration(
             title=_('Data Table'),
             slug='data-table',
             analytics_usage_label="Table",
             analytics_workflow_labels=[
                 clicked_tile, "Clicked Data Table Tile"
             ],
             icon='fcc fcc-datatable-report',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'table']),
             help_text=_(
                 'A table of aggregated data from form submissions or case properties.'
                 ' You choose the columns and rows.'),
         ),
         TileConfiguration(
             title=_('Map'),
             slug='map',
             analytics_usage_label="Map",
             analytics_workflow_labels=[clicked_tile],
             icon='fcc fcc-globe',
             context_processor_class=IconContext,
             url=reverse('report_builder_select_source',
                         args=[self.domain, 'map']),
             help_text=_('A map to show data from your cases or forms.'
                         ' You choose the property to map.'),
         )
     ]
     return tiles