Exemplo n.º 1
0
 def test_without_location_restriction_district(self):
     if self.factory is None:
         return
     view = LocationAncestorsView.as_view()
     url = 'icds_locations_ancestors'
     working_reverse = reverse(url, kwargs={'domain': self.domain.name})
     request = self.factory.get(
         working_reverse, data={'location_id': self.district.location_id})
     request.user = self.user
     response = view(request, domain='icds-test')
     expected = {
         'selected_location': {
             'name': 'Test District',
             'user_have_access_to_parent': False,
             'location_type_name': 'district',
             'user_have_access': True,
             'parent_id': self.state.location_id,
             'location_id': self.district.location_id
         },
         'locations': [{
             'name': 'Test District',
             'user_have_access_to_parent': False,
             'location_type_name': 'district',
             'user_have_access': True,
             'parent_id': self.state.location_id,
             'location_id': self.district.location_id
         }, {
             'name': 'Test District 2',
             'user_have_access_to_parent': False,
             'location_type_name': 'district',
             'user_have_access': True,
             'parent_id': self.state.location_id,
             'location_id': self.district_2.location_id
         }, {
             'name': 'Test State 2',
             'user_have_access_to_parent': False,
             'location_type_name': 'state',
             'user_have_access': True,
             'parent_id': None,
             'location_id': self.state_2.location_id
         }, {
             'name': 'Test State 3',
             'user_have_access_to_parent': False,
             'location_type_name': 'state',
             'user_have_access': True,
             'parent_id': None,
             'location_id': self.state_3.location_id
         }, {
             'name': 'Test State',
             'user_have_access_to_parent': True,
             'location_type_name': 'state',
             'user_have_access': True,
             'parent_id': None,
             'location_id': self.state.location_id
         }]
     }
     self.assertDictEqual(expected, json.loads(response.content))
 def test_without_location_restriction_state(self):
     if self.factory is None:
         return
     view = LocationAncestorsView.as_view()
     url = 'icds_locations_ancestors'
     working_reverse = reverse(url, kwargs={'domain': self.domain.name})
     request = self.factory.get(working_reverse, data={
         'location_id': self.state_3.location_id
     })
     request.user = self.user
     response = view(request, domain='icds-test')
     expected = {
         'selected_location': {
             'name': 'Test State 3',
             'user_have_access_to_parent': False,
             'location_type_name': 'state',
             'user_have_access': True,
             'parent_id': None,
             'location_id': self.state_3.location_id
         },
         'locations': [
             {
                 'name': 'Test State',
                 'user_have_access_to_parent': False,
                 'location_type_name': 'state',
                 'user_have_access': True,
                 'parent_id': None,
                 'location_id': self.state.location_id
             },
             {
                 'name': 'Test State 2',
                 'user_have_access_to_parent': False,
                 'location_type_name': 'state',
                 'user_have_access': True,
                 'parent_id': None,
                 'location_id': self.state_2.location_id
             },
             {
                 'name': 'Test State 3',
                 'user_have_access_to_parent': False,
                 'location_type_name': 'state',
                 'user_have_access': True,
                 'parent_id': None,
                 'location_id': self.state_3.location_id
             }
         ]
     }
     self.assertDictEqual(expected, json.loads(response.content))
Exemplo n.º 3
0
     name='underweight_children'),
 url(r'^prevalence_of_severe/(?P<step>[\w-]+)/',
     PrevalenceOfSevereView.as_view(),
     name='prevalence_of_severe'),
 url(r'^prevalence_of_stunting/(?P<step>[\w-]+)/',
     PrevalenceOfStuntingView.as_view(),
     name='prevalence_of_stunting'),
 url(r'^low_birth/(?P<step>[\w-]+)/',
     NewbornsWithLowBirthWeightView.as_view(),
     name='low_birth'),
 url(r'^early_initiation/(?P<step>[\w-]+)/',
     EarlyInitiationBreastfeeding.as_view(),
     name='early_initiation'),
 url(r'^locations$', LocationView.as_view(), name='icds_locations'),
 url(r'^locations/ancestors$',
     LocationAncestorsView.as_view(),
     name='icds_locations_ancestors'),
 url(r'^export_indicator$',
     ExportIndicatorView.as_view(),
     name='icds_export_indicator'),
 url(r'^fact_sheets$', FactSheetsView.as_view(), name='fact_sheets'),
 url(r'^exclusive-breastfeeding/(?P<step>[\w-]+)/',
     ExclusiveBreastfeedingView.as_view(),
     name='exclusive-breastfeeding'),
 url(r'^children_initiated/(?P<step>[\w-]+)/',
     ChildrenInitiatedView.as_view(),
     name='children_initiated'),
 url(r'^institutional_deliveries/(?P<step>[\w-]+)/',
     InstitutionalDeliveriesView.as_view(),
     name='institutional_deliveries'),
 url(r'^immunization_coverage/(?P<step>[\w-]+)/',
Exemplo n.º 4
0
 def test_with_location_restriction_awc(self):
     if self.factory is None:
         return
     view = LocationAncestorsView.as_view()
     url = 'icds_locations_ancestors'
     working_reverse = reverse(url, kwargs={'domain': self.domain.name})
     request = self.factory.get(working_reverse,
                                data={'location_id': self.awc.location_id})
     self.user.set_location(self.domain.name, self.awc)
     request.user = self.user
     expected = {
         'selected_location': {
             'name': 'Test AWC',
             'user_have_access_to_parent': True,
             'location_type_name': 'awc',
             'user_have_access': True,
             'parent_id': self.supervisor.location_id,
             'location_id': self.awc.location_id
         },
         'locations': [{
             'name': 'Test State',
             'user_have_access_to_parent': True,
             'location_type_name': 'state',
             'user_have_access': False,
             'parent_id': None,
             'location_id': self.state.location_id
         }, {
             'name': 'Test District',
             'user_have_access_to_parent': True,
             'location_type_name': 'district',
             'user_have_access': False,
             'parent_id': self.state.location_id,
             'location_id': self.district.location_id
         }, {
             'name': 'Test Block',
             'user_have_access_to_parent': True,
             'location_type_name': 'block',
             'user_have_access': False,
             'parent_id': self.district.location_id,
             'location_id': self.block.location_id
         }, {
             'name': 'Test Supervisor',
             'user_have_access_to_parent': True,
             'location_type_name': 'supervisor',
             'user_have_access': False,
             'parent_id': self.block.location_id,
             'location_id': self.supervisor.location_id
         }, {
             'name': 'Test AWC',
             'user_have_access_to_parent': True,
             'location_type_name': 'awc',
             'user_have_access': True,
             'parent_id': self.supervisor.location_id,
             'location_id': self.awc.location_id
         }]
     }
     with mock.patch('corehq.apps.users.models.WebUser.has_permission',
                     return_value=False):
         response = view(request, domain='icds-test')
     self.user.unset_location_by_id(self.domain.name, self.awc.location_id)
     self.assertDictEqual(expected, json.loads(response.content))
Exemplo n.º 5
0
     r'^poshan_progress_dashboard/(?P<step>[\w-]+)/',
     PoshanProgressDashboardView.as_view(),
     name='poshan_progress_dashboard'
 ),
 url(
     r'^service_delivery_dashboard_details/(?P<step>[\w-]+)/',
     ServiceDeliveryDashboardDetailsView.as_view(),
     name='service_delivery_dashboard_details'
 ),
 url(r'^maternal_and_child/', include(maternal_and_child_urls)),
 url(r'^icds_cas_reach/', include(cas_reach_urls)),
 url(r'^demographics/', include(demographics_urls)),
 url(r'^awc_infrastructure/', include(awc_infrastructure_urls)),
 url(r'^awc_reports/(?P<step>[\w-]+)/', AwcReportsView.as_view(), name='awc_reports'),
 url(r'^locations$', LocationView.as_view(), name='icds_locations'),
 url(r'^locations/ancestors$', LocationAncestorsView.as_view(), name='icds_locations_ancestors'),
 url(r'^topojson$', TopoJsonView.as_view(), name='topojson'),
 url(r'^icds_export_indicator$', ExportIndicatorView.as_view(), name='icds_export_indicator'),
 url(r'^fact_sheets$', FactSheetsView.as_view(), name='fact_sheets'),
 url(r'^aggregation_script/', AggregationScriptPage.as_view(), name=AggregationScriptPage.urlname),
 url(r'^awc_locations/', AWCLocationView.as_view(), name='awc_locations'),
 url(r'^icds_download_pdf/', DownloadPDFReport.as_view(), name='icds_download_pdf'),
 url(r'^icds_download_excel/', DownloadExportReport.as_view(), name='icds_download_excel'),
 url(r'^issnip_pdf_status/', CheckExportReportStatus.as_view(), name='issnip_pdf_status'),
 url(r'^have_access_to_location/', HaveAccessToLocation.as_view(), name='have_access_to_location'),
 url(r'^inactive_aww', InactiveAWW.as_view(), name='inactive_aww'),
 url(r'^inactive_dashboard_users', InactiveDashboardUsers.as_view(), name='inactive_dashboard_users'),
 url(r'^health_indicators', DishaAPIView.as_view(), name='disha_api'),
 url(r'^nic_indicators', NICIndicatorAPIView.as_view(), name='nic_indicator_api'),
 url(r'^cas_export', CasDataExport.as_view(), name='cas_export'),
 url(r'^ap_webservice', APWebservice.as_view(), name='ap_webservice'),
 def test_with_location_restriction_block(self):
     if self.factory is None:
         return
     view = LocationAncestorsView.as_view()
     url = 'icds_locations_ancestors'
     working_reverse = reverse(url, kwargs={'domain': self.domain.name})
     request = self.factory.get(working_reverse, data={
         'location_id': self.block.location_id
     })
     self.user.set_location(self.domain.name, self.awc)
     request.user = self.user
     expected = {
         'selected_location': {
             'name': 'Test Block',
             'user_have_access_to_parent': True,
             'location_type_name': 'block',
             'user_have_access': False,
             'parent_id': self.district.location_id,
             'location_id': self.block.location_id
         },
         'locations': [
             {
                 'name': 'Test State',
                 'user_have_access_to_parent': True,
                 'location_type_name': 'state',
                 'user_have_access': False,
                 'parent_id': None,
                 'location_id': self.state.location_id
             },
             {
                 'name': 'Test District',
                 'user_have_access_to_parent': True,
                 'location_type_name': 'district',
                 'user_have_access': False,
                 'parent_id': self.state.location_id,
                 'location_id': self.district.location_id
             },
             {
                 'name': 'Test Block',
                 'user_have_access_to_parent': True,
                 'location_type_name': 'block',
                 'user_have_access': False,
                 'parent_id': self.district.location_id,
                 'location_id': self.block.location_id
             },
             {
                 'name': 'Test Supervisor',
                 'user_have_access_to_parent': True,
                 'location_type_name': 'supervisor',
                 'user_have_access': False,
                 'parent_id': self.block.location_id,
                 'location_id': self.supervisor.location_id
             },
             {
                 'name': 'Test AWC',
                 'user_have_access_to_parent': True,
                 'location_type_name': 'awc',
                 'user_have_access': True,
                 'parent_id': self.supervisor.location_id,
                 'location_id': self.awc.location_id
             }
         ]
     }
     with mock.patch('corehq.apps.users.models.WebUser.has_permission', return_value=False):
         response = view(request, domain='icds-test')
     self.user.unset_location_by_id(self.domain.name, self.awc.location_id)
     self.assertDictEqual(expected, json.loads(response.content))
Exemplo n.º 7
0
    url(r'^icds_dashboard/', include(dashboardurls)),
    url(r'^icds-ng-template/(?P<template>[\w-].+)', IcdsDynamicTemplateView.as_view(), name='icds-ng-template'),
    url(r'^program_summary/(?P<step>[\w-]+)/', ProgramSummaryView.as_view(), name='program_summary'),
    url(r'^lady_supervisor/', LadySupervisorView.as_view(), name='lady_supervisor'),
    url(
        r'^service_delivery_dashboard/',
        ServiceDeliveryDashboardView.as_view(),
        name='service_delivery_dashboard'
    ),
    url(r'^maternal_and_child/', include(maternal_and_child_urls)),
    url(r'^icds_cas_reach/', include(cas_reach_urls)),
    url(r'^demographics/', include(demographics_urls)),
    url(r'^awc_infrastructure/', include(awc_infrastructure_urls)),
    url(r'^awc_reports/(?P<step>[\w-]+)/', AwcReportsView.as_view(), name='awc_reports'),
    url(r'^locations$', LocationView.as_view(), name='icds_locations'),
    url(r'^locations/ancestors$', LocationAncestorsView.as_view(), name='icds_locations_ancestors'),
    url(r'^export_indicator$', ExportIndicatorView.as_view(), name='icds_export_indicator'),
    url(r'^fact_sheets$', FactSheetsView.as_view(), name='fact_sheets'),
    url(r'^aggregation_script/', AggregationScriptPage.as_view(), name=AggregationScriptPage.urlname),
    url(r'^bug_report/', ICDSBugReportView.as_view(), name='icds_bug_report'),
    url(r'^awc_locations/', AWCLocationView.as_view(), name='awc_locations'),
    url(r'^download_pdf/', DownloadPDFReport.as_view(), name='icds_download_pdf'),
    url(r'^download_excel/', DownloadExportReport.as_view(), name='icds_download_excel'),
    url(r'^issnip_pdf_status/', CheckExportReportStatus.as_view(), name='issnip_pdf_status'),
    url(r'^have_access_to_location/', HaveAccessToLocation.as_view(), name='have_access_to_location'),
    url(r'^inactive_aww', InactiveAWW.as_view(), name='inactive_aww'),
    url(r'^inactive_dashboard_users', InactiveDashboardUsers.as_view(), name='inactive_aww'),
    url(r'^health_indicators', DishaAPIView.as_view(), name='disha_api'),
    url(r'^cas_export', CasDataExport.as_view(), name='cas_export'),
]