Ejemplo n.º 1
0
    def test_get_unvalidated_records_as_validator(self):
        view = GetNonValidatedRecords.as_view()
        BiologicalCollectionRecordF.create(
            original_species_name=u'Aves collection 1',
            site=self.location_site,
            validated=False,
            ready_for_validation=True,
            taxonomy=self.taxonomy_1)
        BiologicalCollectionRecordF.create(
            original_species_name=u'Aves collection 2',
            site=self.location_site,
            validated=False,
            ready_for_validation=True,
            taxonomy=self.taxonomy_2)
        user = UserF.create()
        content_type = ContentTypeF.create(app_label='bims', model='bims')
        permission = PermissionF.create(name='Can validate Aves',
                                        content_type=content_type,
                                        codename='can_validate_aves')
        group = GroupF.create()
        group.permissions.add(permission)
        user.groups.add(group)

        request = self.factory.get(reverse('get-unvalidated-records'))
        request.user = user
        response = view(request)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data['data']), 2)
Ejemplo n.º 2
0
    def test_get_unvalidated_records_as_validator(self):
        view = GetNonValidatedRecords.as_view()
        user = UserF.create()
        content_type = ContentTypeF.create(app_label='bims', model='bims')
        permission = PermissionF.create(name='Can validate data',
                                        content_type=content_type,
                                        codename='can_validate_data')
        group = GroupF.create()
        group.permissions.add(permission)
        user.groups.add(group)

        request = self.factory.get(reverse('get-unvalidated-records'))
        request.user = user
        response = view(request)
        self.assertEqual(response.status_code, 200)
Ejemplo n.º 3
0
    def test_only_get_aves_collection(self):
        from django.contrib.auth.models import Permission
        view = GetNonValidatedRecords.as_view()
        BiologicalCollectionRecordF.create(site=self.location_site,
                                           taxonomy=self.taxonomy_class_1,
                                           validated=False)
        user = UserF.create()
        permission = Permission.objects.filter(codename='can_validate_aves')[0]
        group = GroupF.create()
        group.permissions.add(permission)
        user.groups.add(group)

        request = self.factory.get(reverse('get-unvalidated-records'))
        request.user = user
        response = view(request)
        self.assertEqual(response.status_code, 200)
Ejemplo n.º 4
0
 def test_get_unvalidated_records_as_admin(self):
     view = GetNonValidatedRecords.as_view()
     request = self.factory.get(reverse('get-unvalidated-records'))
     request.user = self.admin_user
     response = view(request)
     self.assertEqual(response.status_code, 200)
Ejemplo n.º 5
0
        CollectorList.as_view(), name='list-collector'),
    url(r'^api/list-category/$',
        CategoryList.as_view(), name='list-date-category'),
    url(r'^api/list-reference/$',
        ReferenceList.as_view(), name='list-reference'),
    url(r'^api/list-non-biodiversity/$',
        NonBiodiversityLayerList.as_view(),
        name='list-non-biodiversity-layer'),
    url(r'^api/validate-object/$',
        ValidateObject.as_view(), name='validate-object'),
    url(r'^api/get-bio-object/$',
        GetBioRecordDetail.as_view(), name='get-bio-object'),
    url(r'^api/get-bio-records/$',
        GetBioRecords.as_view(), name='get-bio-records'),
    url(r'^api/get-unvalidated-records/$',
        GetNonValidatedRecords.as_view(), name='get-unvalidated-records'),
    url(r'^api/send-email-validation/$',
        SendNotificationValidation.as_view(), name='send-email-validation'),
    url(r'^api/filter-farm-id/$',
        filter_farm_ids_view, name='filter-farm-id'),
    url(r'^api/get-farm/(?P<farm_id>[\w-]+)/$',
        get_farm_view, name='get-farm'),
    url(r'api/hide-popup-info/$',
        HidePopupInfoUser.as_view(), name='hide-popup-user'),
    url(r'^api/list-reference-category/$',
        ReferenceCategoryList.as_view(), name='list-reference-category'),
]


urlpatterns = [
    url(r'^$', LandingPageView.as_view(), name='landing-page'),
Ejemplo n.º 6
0
     name='reject-collection-data'),
 url(r'^get-bio-object/$',
     GetBioRecordDetail.as_view(),
     name='get-bio-object'),
 url(r'^get-site-code/$', GetSiteCode.as_view(), name='get-site-code'),
 url(r'^get-river-name/$', GetRiverName.as_view(), name='get-river-name'),
 url(r'^get-geomorphological-zone/$',
     GetGeomorphologicalZone.as_view(),
     name='get-geomorphological-zone'),
 url(r'^get-bio-records/$', GetBioRecords.as_view(),
     name='get-bio-records'),
 url(r'^bio-collection-summary/$',
     BioCollectionSummary.as_view(),
     name='bio-collection-summary'),
 url(r'^get-unvalidated-records/$',
     GetNonValidatedRecords.as_view(),
     name='get-unvalidated-records'),
 url(r'^send-email-validation/$',
     SendNotificationValidation.as_view(),
     name='send-email-validation'),
 url(r'^filter-farm-id/$', filter_farm_ids_view, name='filter-farm-id'),
 url(r'^get-farm/(?P<farm_id>[\w-]+)/$', get_farm_view, name='get-farm'),
 url(r'hide-popup-info/$',
     HidePopupInfoUser.as_view(),
     name='hide-popup-user'),
 url(r'^list-reference-category/$',
     ReferenceCategoryList.as_view(),
     name='list-reference-category'),
 url(r'^list-source-collection/$',
     SourceCollectionList.as_view(),
     name='list-source-collection'),