'title': _(report.name), 'subpages': report.get_subpages(), 'show_in_dropdown': report.display_in_dropdown(project=project), }) if report_contexts: if hasattr(section_name, '__call__'): section_name = section_name(project, couch_user) nav_context.append((section_name, report_contexts)) return nav_context @classmethod def url_pattern(cls): from django.conf.urls import url return url(cls.pattern(), cls.as_view(), name=cls.name()) cls_to_view_login_and_domain = cls_to_view(additional_decorator=login_and_domain_required) class ProjectReportDispatcher(ReportDispatcher): prefix = 'project_report' # string. ex: project, custom, billing, interface, admin map_name = 'REPORTS' @property def slug_aliases(self): return { 'daily_completions': 'daily_form_stats', 'daily_submissions': 'daily_form_stats', 'submit_time_punchcard': 'worker_activity_times', } @cls_to_view_login_and_domain
from __future__ import absolute_import from corehq.apps.domain.decorators import cls_to_view from corehq.apps.reports.dispatcher import ReportDispatcher from corehq.apps.users.decorators import require_permission from corehq.apps.users.models import Permissions # this is the permissions setting that makes the most sense now, # but perhaps there should be a specific edit_indicators permission? require_edit_indicators = require_permission(Permissions.edit_data) cls_require_edit_indicators = cls_to_view( additional_decorator=require_edit_indicators) class IndicatorAdminInterfaceDispatcher(ReportDispatcher): prefix = "indicator_admin_interface" map_name = "INDICATOR_ADMIN_INTERFACES" @cls_require_edit_indicators def dispatch(self, request, *args, **kwargs): return super(IndicatorAdminInterfaceDispatcher, self).dispatch(request, *args, **kwargs)
'show_in_dropdown': show_in_dropdown, 'class_name': report.__name__, }) if report_contexts: if hasattr(section_name, '__call__'): section_name = section_name(project, couch_user) nav_context.append((section_name, report_contexts)) return nav_context @classmethod def url_pattern(cls): from django.conf.urls import re_path as url return url(cls.pattern(), cls.as_view(), name=cls.name()) cls_to_view_login_and_domain = cls_to_view(additional_decorator=login_and_domain_required) class ProjectReportDispatcher(ReportDispatcher): prefix = 'project_report' # string. ex: project, custom, billing, interface, admin map_name = 'REPORTS' @property def slug_aliases(self): return { 'daily_completions': 'daily_form_stats', 'daily_submissions': 'daily_form_stats', 'submit_time_punchcard': 'worker_activity_times', } @cls_to_view_login_and_domain
import datetime from corehq.apps.domain.decorators import cls_to_view, require_previewer from corehq.apps.domain.models import Domain from corehq.apps.reports.dispatcher import ReportDispatcher, ProjectReportDispatcher from corehq.apps.reports.views import datespan_default cls_require_previewer = cls_to_view(additional_decorator=require_previewer) class AppstoreDispatcher(ReportDispatcher): prefix = "appstore_interface" map_name = "APPSTORE_INTERFACE_MAP" @cls_require_previewer @datespan_default def dispatch(self, request, *args, **kwargs): # HACK HACK HACK HACK HACK from Tim, just moving it over # todo fix HACK HACK HACK HACK HACK dummy = Domain.get_by_name("dumdum") if not dummy: dummy = Domain(name="dumdum", is_active=True, date_created=datetime.datetime.utcnow()) dummy.save() kwargs["domain"] = "dumdum" return super(AppstoreDispatcher, self).dispatch(request, *args, **kwargs) @classmethod def args_kwargs_from_context(cls, context): return ProjectReportDispatcher.args_kwargs_from_context(context)
from corehq.apps.data_interfaces.views import require_can_edit_data from corehq.apps.domain.decorators import cls_to_view from corehq.apps.reports.dispatcher import ReportDispatcher, ProjectReportDispatcher from corehq.apps.reports.views import datespan_default cls_require_edit_data = cls_to_view(additional_decorator=require_can_edit_data) class DataInterfaceDispatcher(ReportDispatcher): prefix = 'data_interface' map_name = 'DATA_INTERFACE_MAP' @cls_require_edit_data @datespan_default def dispatch(self, request, *args, **kwargs): return super(DataInterfaceDispatcher, self).dispatch(request, *args, **kwargs) def permissions_check(self, report, request, *args, **kwargs): domain = kwargs.get('domain') if domain is None: domain = args[0] return request.couch_user.can_edit_data(domain) @classmethod def args_kwargs_from_context(cls, context): return ProjectReportDispatcher.args_kwargs_from_context(context)
from corehq.apps.domain.decorators import cls_to_view from corehq.apps.reports.dispatcher import ReportDispatcher from corehq.apps.users.decorators import require_permission from corehq.apps.users.models import Permissions # this is the permissions setting that makes the most sense now, # but perhaps there should be a specific edit_indicators permission? require_edit_indicators = require_permission(Permissions.edit_data) cls_require_edit_indicators = cls_to_view(additional_decorator=require_edit_indicators) class IndicatorAdminInterfaceDispatcher(ReportDispatcher): prefix = "indicator_admin_interface" map_name = "INDICATOR_ADMIN_INTERFACES" @cls_require_edit_indicators def dispatch(self, request, *args, **kwargs): return super(IndicatorAdminInterfaceDispatcher, self).dispatch(request, *args, **kwargs)
from corehq.apps.data_interfaces.views import require_can_edit_data from corehq.apps.domain.decorators import cls_to_view from corehq.apps.reports.dispatcher import ReportDispatcher from corehq.apps.reports.views import datespan_default cls_require_edit_data = cls_to_view(additional_decorator=require_can_edit_data) class DataInterfaceDispatcher(ReportDispatcher): prefix = 'data_interface' map_name = 'DATA_INTERFACES' @cls_require_edit_data @datespan_default def dispatch(self, request, *args, **kwargs): return super(DataInterfaceDispatcher, self).dispatch(request, *args, **kwargs) def permissions_check(self, report, request, domain=None): return request.couch_user.can_edit_data(domain)