def default_data_view_url(request, domain): if request.couch_user.can_view_reports(): return reverse(DataInterfaceDispatcher.name(), args=[domain, ExcelExportReport.slug]) exportable_reports = request.couch_user.get_exportable_reports(domain) if exportable_reports: return reverse(DataInterfaceDispatcher.name(), args=[domain, exportable_reports[0]]) if request.couch_user.can_edit_data(): return reverse(EditDataInterfaceDispatcher.name(), args=[domain, CaseReassignmentInterface.slug]) raise Http404()
def default(request, domain): if not request.project or request.project.is_snapshot: raise Http404() if request.couch_user.can_view_reports(): return HttpResponseRedirect(reverse(DataInterfaceDispatcher.name(), args=[domain, ExcelExportReport.slug])) exportable_reports = request.couch_user.get_exportable_reports(domain) if exportable_reports: return HttpResponseRedirect(reverse(DataInterfaceDispatcher.name(), args=[domain, exportable_reports[0]])) if request.couch_user.can_edit_data(): return HttpResponseRedirect(reverse(EditDataInterfaceDispatcher.name(), args=[domain, CaseReassignmentInterface.slug])) raise Http404()
def sidebar_items(self): items = [] context = { 'request': self._request, 'domain': self.domain, } if self.can_export_data: from corehq.apps.data_interfaces.dispatcher import DataInterfaceDispatcher items.extend(DataInterfaceDispatcher.navigation_sections(context)) if self.can_edit_commcare_data: from corehq.apps.data_interfaces.dispatcher import EditDataInterfaceDispatcher edit_section = EditDataInterfaceDispatcher.navigation_sections(context) from corehq.apps.data_interfaces.views import CaseGroupListView, CaseGroupCaseManagementView if self.couch_user.is_previewer: edit_section[0][1].append({ 'title': CaseGroupListView.page_title, 'url': reverse(CaseGroupListView.urlname, args=[self.domain]), 'subpages': [ { 'title': CaseGroupCaseManagementView.page_title, 'urlname': CaseGroupCaseManagementView.urlname, } ] }) items.extend(edit_section) return items
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_user_roles(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
def hq_update_saved_export(req, domain): group_id = req.POST["group_export_id"] index = int(req.POST["index"]) group_config = HQGroupExportConfiguration.get(group_id) assert domain == group_config.domain config, schema = group_config.all_exports[index] rebuild_export(config, schema, "couch") messages.success(req, _("The data for {} has been refreshed!").format(config.name)) return HttpResponseRedirect(reverse(DataInterfaceDispatcher.name(), args=[domain, req.POST["report_slug"]]))
def default(request, domain): # context = { # 'domain': domain, # 'slug': None, # 'report': {'name': "Select a Data Interface to View"} # } # return render_to_response(request, template, context) from corehq.apps.data_interfaces.dispatcher import DataInterfaceDispatcher return HttpResponseRedirect(reverse(DataInterfaceDispatcher.name(), args=[domain, 'reassign_cases']))
def hq_update_saved_export(req, domain): group_id = req.POST['group_export_id'] index = int(req.POST['index']) group_config = HQGroupExportConfiguration.get(group_id) assert domain == group_config.domain config, schema = group_config.all_exports[index] rebuild_export(config, schema, 'couch') messages.success( req, _('The data for {} has been refreshed!').format(config.name)) return HttpResponseRedirect( reverse(DataInterfaceDispatcher.name(), args=[domain, req.POST['report_slug']]))
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
url(r'^xform_management/$', XFormManagementView.as_view(), name=XFormManagementView.urlname), url( r'^xform_management/status/(?P<mode>{archive}|{restore})/(?P<download_id>{id_regex})/$'.format( archive=FormManagementMode.ARCHIVE_MODE, restore=FormManagementMode.RESTORE_MODE, id_regex="[0-9a-fA-Z]{25,32}", ), XFormManagementStatusView.as_view(), name=XFormManagementStatusView.urlname ), url(r'^xform_management/status/poll/(?P<download_id>[0-9a-fA-Z]{25,32})/$', xform_management_job_poll, name='xform_management_job_poll'), url(r'^case_groups/$', CaseGroupListView.as_view(), name=CaseGroupListView.urlname), url(r'^case_groups/(?P<group_id>[\w-]+)/$', CaseGroupCaseManagementView.as_view(), name=CaseGroupCaseManagementView.urlname), url(r'^automatic_updates/$', AutomaticUpdateRuleListView.as_view(), name=AutomaticUpdateRuleListView.urlname), url(r'^automatic_updates/add/$', AddAutomaticUpdateRuleView.as_view(), name=AddAutomaticUpdateRuleView.urlname), url(r'^automatic_updates/edit/(?P<rule_id>\d+)/$', EditAutomaticUpdateRuleView.as_view(), name=EditAutomaticUpdateRuleView.urlname), EditDataInterfaceDispatcher.url_pattern(), ] urlpatterns = [ url(r'^$', default, name="data_interfaces_default"), url(r'^edit/', include(edit_data_urls)), url(r'^export/', include('corehq.apps.export.urls')), DataInterfaceDispatcher.url_pattern(), ]
), XFormManagementStatusView.as_view(), name=XFormManagementStatusView.urlname), url(r'^xform_management/status/poll/(?P<download_id>[0-9a-fA-Z]{25,32})/$', xform_management_job_poll, name='xform_management_job_poll'), url(r'^case_groups/$', CaseGroupListView.as_view(), name=CaseGroupListView.urlname), url(r'^case_groups/(?P<group_id>[\w-]+)/$', CaseGroupCaseManagementView.as_view(), name=CaseGroupCaseManagementView.urlname), url(r'^automatic_updates/$', AutomaticUpdateRuleListView.as_view(), name=AutomaticUpdateRuleListView.urlname), url(r'^automatic_updates/add/$', AddAutomaticUpdateRuleView.as_view(), name=AddAutomaticUpdateRuleView.urlname), url(r'^automatic_updates/edit/(?P<rule_id>\d+)/$', EditAutomaticUpdateRuleView.as_view(), name=EditAutomaticUpdateRuleView.urlname), EditDataInterfaceDispatcher.url_pattern(), ] urlpatterns = [ url(r'^$', default, name="data_interfaces_default"), url(r'^edit/', include(edit_data_urls)), url(r'^export/', include('corehq.apps.export.urls')), DataInterfaceDispatcher.url_pattern(), ]
from django.conf.urls.defaults import * from corehq.apps.data_interfaces.dispatcher import DataInterfaceDispatcher urlpatterns = patterns('corehq.apps.data_interfaces.views', url(r'^$', "default", name="data_interfaces_default"), url(DataInterfaceDispatcher.pattern(), DataInterfaceDispatcher.as_view(), name=DataInterfaceDispatcher.name() ) )
def default(request, domain): from corehq.apps.data_interfaces.dispatcher import DataInterfaceDispatcher return HttpResponseRedirect(reverse(DataInterfaceDispatcher.name(), args=[domain, 'reassign_cases']))
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()) can_view_commtrack_setup = lambda request: (request.project.commtrack_enabled) 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_domain_admin = lambda request: request.couch_user.is_domain_admin(request.domain) data_url_generator = lambda urlname, request: reverse(urlname, args=[request.domain, ExcelExportReport.slug]) 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=IconContext, urlname=DataInterfaceDispatcher.name(), url_generator=data_url_generator, 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_edit_apps, 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_domain_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"), ), ]
def default(request, domain): from corehq.apps.data_interfaces.dispatcher import DataInterfaceDispatcher return HttpResponseRedirect( reverse(DataInterfaceDispatcher.name(), args=[domain, 'reassign_cases']))