Example #1
0
    def add_test_organizations(self):
        orgs = []
        orgs.append(OrganizationFactory.create(
            name='Habitat for Humanity (Test)', slug='habitat-for-humanity',
            description="""Habitat for Humanity is a nonprofit, ecumenical Christian ministry
        that builds with people in need regardless of race or religion. Since
        1976, Habitat has helped 6.8 million people find strength, stability
        and independence through safe, decent and affordable shelter.""",
            urls=['http://www.habitat.org'],
            logo='https://s3.amazonaws.com/cadasta-dev-tmp/logos/h4h.png',
            contacts=[{'email': '*****@*****.**'}]
        ))
        orgs.append(OrganizationFactory.create(
            name='Cadasta (Test)', slug='cadasta',
            description="""Cadasta Foundation is dedicated to the support, continued
        development and growth of the Cadasta Platform – an innovative, open
        source suite of tools for the collection and management of ownership,
        occupancy, and spatial data that meets the unique challenges of this
        process in much of the world.""",
            urls=['http://www.cadasta.org'],
            logo='https://s3.amazonaws.com/cadasta-dev-tmp/logos/cadasta.png',
            contacts=[{'email': '*****@*****.**'}]
        ))

        print('\nSuccessfully added organizations:')
        for org in models.Organization.objects.all():
            print(org.name)
Example #2
0
    def add_test_organizations(self):
        orgs = []
        orgs.append(OrganizationFactory.create(
            name='Habitat for Humanity (Test)', slug='habitat-for-humanity',
            description="""Habitat for Humanity is a nonprofit, ecumenical Christian ministry
        that builds with people in need regardless of race or religion. Since
        1976, Habitat has helped 6.8 million people find strength, stability
        and independence through safe, decent and affordable shelter.""",
            urls=['http://www.habitat.org'],
            logo='https://s3.amazonaws.com/cadasta-dev-tmp/logos/h4h.png',
            contacts=[{'email': '*****@*****.**'}]
        ))
        orgs.append(OrganizationFactory.create(
            name='Cadasta (Test)', slug='cadasta',
            description="""Cadasta Foundation is dedicated to the support, continued
        development and growth of the Cadasta Platform – an innovative, open
        source suite of tools for the collection and management of ownership,
        occupancy, and spatial data that meets the unique challenges of this
        process in much of the world.""",
            urls=['http://www.cadasta.org'],
            logo='https://s3.amazonaws.com/cadasta-dev-tmp/logos/cadasta.png',
            contacts=[{'email': '*****@*****.**'}]
        ))

        print('\nSuccessfully added organizations:')
        for org in Organization.objects.all():
            print(org.name)
    def test_archived_orgs_filter_appears_in_long_list(self):
        """If the organization list spans two pages, and an archived
        organization appears on the second page, the archive filter option
        should still appear"""
        OrganizationFactory.create_batch(10)

        LoginPage(self).login('testadmin', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        page.sort_table_by("ascending", col="organization")
        page.click_archive_filter("All")
        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("ascending", col="organization")
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        page.click_archive_filter("Active")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'
    def test_archived_orgs_filter_appears_in_long_list(self):
        """If the organization list spans two pages, and an archived
        organization appears on the second page, the archive filter option
        should still appear"""
        OrganizationFactory.create_batch(10)

        LoginPage(self).login('testadmin', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        page.sort_table_by("ascending", col="organization")
        page.click_archive_filter("All")
        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("ascending", col="organization")
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        page.click_archive_filter("Active")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'
 def setup_models(self):
     self.u1 = UserFactory.create()
     self.u2 = UserFactory.create()
     self.u3 = UserFactory.create()
     self.org1 = OrganizationFactory.create(name='A', add_users=[self.u1])
     self.org2 = OrganizationFactory.create(
         name='B', add_users=[self.u1, self.u2]
     )
     self.user = UserFactory.create()
Example #6
0
    def test_with_organizations_and_projects(self):
        user = UserFactory.create()
        org1, org2 = OrganizationFactory.create_batch(2)

        proj1, proj2 = ProjectFactory.create_batch(2, organization=org1)
        proj3 = ProjectFactory.create(organization=org2)
        proj4 = ProjectFactory.create(organization=org2, archived=False)

        ProjectRole.objects.create(project=proj1, user=user, role='DC')
        is_not_admin_org1 = OrganizationRole.objects.create(organization=org1,
                                                            user=user,
                                                            admin=False).admin
        is_admin_org2 = OrganizationRole.objects.create(organization=org2,
                                                        user=user,
                                                        admin=True).admin

        response = self.request(user=user)

        assert response.status_code == 200
        assert response.content == self.render_content(user_orgs_and_projects=[
            (org1, is_not_admin_org1,
             [(proj2, 'Public User'), (proj1, 'Data Collector')]),
            (org2, is_admin_org2,
             [(proj3, 'Administrator'), (proj4, 'Administrator')]),
        ])
 def setup_models(self):
     self.user = UserFactory.create()
     assign_policies(self.user)
     self.org = OrganizationFactory.create()
     self.prj = ProjectFactory.create(
         organization=self.org, add_users=[self.user])
     self.party = PartyFactory.create(name="Test Party", project=self.prj)
Example #8
0
    def _test_get_private_record(
        self,
        status,  # Expected HTTP status status_code
        user=None,  # Optional user that does the update
        make_org_member=False,  # Flag to make the user an org member
        make_other_org_member=False  # Flag to make the user a member
        # of another org
    ):
        # Set up request
        record, org = self._test_objs(access="private")
        if user is None:
            user = self.user
        if make_org_member:
            OrganizationRole.objects.create(organization=org, user=user)
        if make_other_org_member:
            other_org = OrganizationFactory.create()
            OrganizationRole.objects.create(organization=other_org, user=user)

        # Perform request
        content = self._get(
            org_slug=org.slug, prj_slug=record.project.slug, record_id=record.id, user=user, status=status
        )

        # Perform post-checks
        if status == status_code.HTTP_200_OK:
            assert self.is_id_in_content(content, record.id)
        if status == status_code.HTTP_403_FORBIDDEN:
            assert content["detail"] == PermissionDenied.default_detail
 def setup_models(self):
     self.user = UserFactory.create()
     assign_policies(self.user)
     self.org = OrganizationFactory.create()
     self.prj = ProjectFactory.create(
         organization=self.org, add_users=[self.user])
     self.party = PartyFactory.create(name="Test Party", project=self.prj)
Example #10
0
    def test_login_redirect_from_org_dashboard_to_dashboard(self):
        user = UserFactory.create()
        assign_user_policies(user, *[])
        org = OrganizationFactory.create()
        view = org_views.OrganizationDashboard.as_view()

        request = HttpRequest()
        request.META['HTTP_REFERER'] = '/account/login/'
        setattr(request, 'user', user)
        setattr(request, 'method', 'GET')

        setattr(request, 'session', 'session')
        self.messages = FallbackStorage(request)
        setattr(request, '_messages', self.messages)

        kwargs = {'slug': org.slug}

        def get_full_path():
            return '/organizations/{}/'.format(org.slug)

        setattr(request, 'get_full_path', get_full_path)

        exp_redirect = reverse('core:dashboard')
        response = view(request, **kwargs)
        assert response.status_code == 302
        assert exp_redirect == response['location']
    def setup_models(self):
        self.user = UserFactory.create()
        self.org = OrganizationFactory.create()
        self.prj = ProjectFactory.create(organization=self.org)

        OrganizationRole.objects.create(
            organization=self.org, user=self.user, admin=True)
Example #12
0
    def test_login_redirect_from_org_dashboard_to_dashboard(self):
        user = UserFactory.create()
        assign_user_policies(user, *[])
        org = OrganizationFactory.create()
        view = org_views.OrganizationDashboard.as_view()

        request = HttpRequest()
        request.META['HTTP_REFERER'] = '/account/login/'
        setattr(request, 'user', user)
        setattr(request, 'method', 'GET')

        setattr(request, 'session', 'session')
        self.messages = FallbackStorage(request)
        setattr(request, '_messages', self.messages)

        kwargs = {'slug': org.slug}

        def get_full_path():
            return '/organizations/{}/'.format(org.slug)
        setattr(request, 'get_full_path', get_full_path)

        exp_redirect = reverse('core:dashboard')
        response = view(request, **kwargs)
        assert response.status_code == 302
        assert exp_redirect == response['location']
Example #13
0
    def setup_models(self):
        self.user = UserFactory.create()
        self.org = OrganizationFactory.create()
        self.prj = ProjectFactory.create(organization=self.org)

        OrganizationRole.objects.create(
            organization=self.org, user=self.user, admin=True)
    def setup_models(self):
        self.user = UserFactory.create()
        assign_policies(self.user)

        self.org = OrganizationFactory.create(slug="namati")
        self.prj = ProjectFactory.create(slug="test-project", organization=self.org, access="public")
        self.party1 = PartyFactory.create(project=self.prj, name="Landowner")
        self.party2 = PartyFactory.create(project=self.prj, name="Leaser")
Example #15
0
def load_test_data(data):
    retval = {}

    # Load users
    if 'users' in data:
        user_objs = []  # For assigning members to orgs later
        for user in data['users']:
            if '_is_superuser' in user and user['_is_superuser']:
                user_objs.append(
                    create_superuser(username=user['username'],
                                     password=user['password'],
                                     email=user['email'] if
                                     ('email' in user) else None))
            else:
                user_objs.append(UserFactory.create(**user))
    retval['users'] = user_objs

    # Load orgs
    org_objs = []  # For anchoring projects to orgs later
    if 'orgs' in data:
        for org in data['orgs']:
            kwargs = org.copy()
            for key in ('_members', '_admins'):
                if key in org:
                    del kwargs[key]
            org_obj = OrganizationFactory.create(**kwargs)
            org_objs.append(org_obj)
            if '_members' in org:
                admin_idxs = []
                if '_admins' in org:
                    admin_idxs = org['_admins']
                for member_idx in org['_members']:
                    OrganizationRole.objects.create(
                        organization=org_obj,
                        user=user_objs[member_idx],
                        admin=member_idx in admin_idxs,
                    )
    retval['organizations'] = org_objs

    # Load projects
    proj_objs = []
    if 'projects' in data:
        for project in data['projects']:
            assert '_org' in project
            kwargs = project.copy()
            kwargs['organization'] = org_objs[kwargs['_org']]
            del kwargs['_org']
            if '_managers' in project:
                org_idx = project['_org']
                org_member_idxs = data['orgs'][org_idx]['_members']
                for idx in project['_managers']:
                    assert idx in org_member_idxs
                del kwargs['_managers']
            proj_obj = ProjectFactory.create(**kwargs)
            proj_objs.append(proj_obj)
    retval['projects'] = proj_objs

    return retval
    def setup_models(self):
        self.user = UserFactory.create()
        assign_policies(self.user)

        self.org = OrganizationFactory.create(slug='namati')
        self.prj = ProjectFactory.create(
            slug='test-project', organization=self.org, access='public')
        self.party1 = PartyFactory.create(project=self.prj, name='Landowner')
        self.party2 = PartyFactory.create(project=self.prj, name='Leaser')
Example #17
0
    def test_with_organizations_without_projects(self):
        user = UserFactory.create()
        org = OrganizationFactory.create()
        orgrole = OrganizationRole.objects.create(organization=org, user=user)

        response = self.request(user=user)

        assert response.status_code == 200
        assert response.content == self.render_content(
            user_orgs_and_projects=[(org, orgrole.admin, [])])
    def setup_models(self):
        self.user = UserFactory.create()
        assign_policies(self.user)

        self.org = OrganizationFactory.create(slug='namati')
        self.prj = ProjectFactory.create(slug='test-project',
                                         organization=self.org,
                                         access='public')
        self.party1 = PartyFactory.create(project=self.prj, name='Landowner')
        self.party2 = PartyFactory.create(project=self.prj, name='Leaser')
Example #19
0
def load_test_data(data):
    retval = {}

    # Load users
    if 'users' in data:
        user_objs = []  # For assigning members to orgs later
        for user in data['users']:
            # Drop all keys starting with an underscore for user creation
            args = {k: v for k, v in user.items() if not k.startswith('_')}
            user_objs.append(UserFactory.create(**args))
            if user.get('_is_superuser'):
                assign_superuser_role(user_objs[-1])
    retval['users'] = user_objs

    # Load orgs
    org_objs = []  # For anchoring projects to orgs later
    if 'orgs' in data:
        for org in data['orgs']:
            kwargs = org.copy()
            for key in ('_members', '_admins'):
                if key in org:
                    del kwargs[key]
            org_obj = OrganizationFactory.create(**kwargs)
            org_objs.append(org_obj)
            if '_members' in org:
                admin_idxs = []
                if '_admins' in org:
                    admin_idxs = org['_admins']
                for member_idx in org['_members']:
                    OrganizationRole.objects.create(
                        organization=org_obj,
                        user=user_objs[member_idx],
                        admin=member_idx in admin_idxs,
                    )
    retval['organizations'] = org_objs

    # Load projects
    proj_objs = []
    if 'projects' in data:
        for project in data['projects']:
            assert '_org' in project
            kwargs = project.copy()
            kwargs['organization'] = org_objs[kwargs['_org']]
            del kwargs['_org']
            if '_managers' in project:
                org_idx = project['_org']
                org_member_idxs = data['orgs'][org_idx]['_members']
                for idx in project['_managers']:
                    assert idx in org_member_idxs
                del kwargs['_managers']
            proj_obj = ProjectFactory.create(**kwargs)
            proj_objs.append(proj_obj)
    retval['projects'] = proj_objs

    return retval
 def setup_models(self):
     self.org = OrganizationFactory.create()
     extent = ('SRID=4326;'
               'POLYGON ((-5.1031494140625000 8.1299292850467957, '
               '-5.0482177734375000 7.6837733211111425, '
               '-4.6746826171875000 7.8252894725496338, '
               '-4.8641967773437491 8.2278005261522775, '
               '-5.1031494140625000 8.1299292850467957))')
     ProjectFactory.create(organization=self.org, extent=extent)
     ProjectFactory.create(organization=self.org, extent=extent)
     ProjectFactory.create(
         name='Private Project',
         access='private', organization=self.org, extent=extent)
Example #21
0
    def setup_models(self):
        clause = {
            'clause': [{
                'effect': 'allow',
                'object': ['project/*/*'],
                'action': ['questionnaire.*']
            }]
        }
        policy = Policy.objects.create(name='test-policy',
                                       body=json.dumps(clause))
        self.user = UserFactory.create()
        self.user.assign_policies(policy)

        self.org = OrganizationFactory.create()
        self.prj = ProjectFactory.create(organization=self.org)
 def setup_models(self):
     self.org = OrganizationFactory.create()
     extent = ('SRID=4326;'
               'POLYGON ((-5.1031494140625000 8.1299292850467957, '
               '-5.0482177734375000 7.6837733211111425, '
               '-4.6746826171875000 7.8252894725496338, '
               '-4.8641967773437491 8.2278005261522775, '
               '-5.1031494140625000 8.1299292850467957))')
     ProjectFactory.create(organization=self.org, extent=extent)
     ProjectFactory.create(organization=self.org, extent=extent)
     ProjectFactory.create(
         name='Private Project',
         access='private', organization=self.org, extent=extent)
     ProjectFactory.create(
         name='Archived Project', archived=True,
         organization=self.org, extent=extent)
Example #23
0
    def _test_patch_private_record(
        self,
        get_new_data,  # Callback to return partially updated record
        status,  # Expected HTTP status status_code
        user=None,  # Optional user that does the update
        make_org_member=False,  # Flag to make the user an org member
        make_org_admin=False,  # Flag to make the user an org admin
        make_other_org_member=False  # Flag to make the user a member
        # of another org
    ):
        # Set up request
        existing_record, org = self._test_objs(access="private")
        if user is None:
            user = self.user
        if make_org_member:
            OrganizationRole.objects.create(organization=org, user=user)
        if make_org_admin:
            OrganizationRole.objects.create(organization=org, user=user, admin=True)
        if make_other_org_member:
            other_org = OrganizationFactory.create()
            OrganizationRole.objects.create(organization=other_org, user=user)

        # Perform request
        content = self._patch(
            org_slug=org.slug,
            prj_slug=existing_record.project.slug,
            record=existing_record,
            user=user,
            data=get_new_data(),
            status=status,
        )

        # Perform post-checks
        if status == status_code.HTTP_403_FORBIDDEN:
            assert content["detail"] == PermissionDenied.default_detail
        if status != status_code.HTTP_200_OK:
            existing_content = self._get(
                org_slug=org.slug,
                prj_slug=existing_record.project.slug,
                record_id=existing_record.id,
                user=self.user,
                status=status_code.HTTP_200_OK,
            )
            self.check_for_unchanged(existing_content)
        return content
    def setup_models(self):
        clause = {
            'clause': [
                {
                    'effect': 'allow',
                    'object': ['project/*/*'],
                    'action': ['questionnaire.*']
                }
            ]
        }
        policy = Policy.objects.create(
            name='test-policy',
            body=json.dumps(clause))
        self.user = UserFactory.create()
        self.user.assign_policies(policy)

        self.org = OrganizationFactory.create()
        self.prj = ProjectFactory.create(organization=self.org)
Example #25
0
    def test_login_redirect_to_organization_dashboard(self):
        user = UserFactory.create()
        org = OrganizationFactory.create()

        view = org_views.OrganizationEdit.as_view()

        request = HttpRequest()
        request.META['HTTP_REFERER'] = '/account/login/'
        setattr(request, 'user', user)
        setattr(request, 'method', 'GET')

        setattr(request, 'session', 'session')
        self.messages = FallbackStorage(request)
        setattr(request, '_messages', self.messages)

        kwargs = {'slug': org.slug}

        exp_redirect = reverse('organization:dashboard', kwargs=kwargs)
        response = view(request, **kwargs)
        assert response.status_code == 302
        assert exp_redirect == response['location']
Example #26
0
    def test_login_redirect_to_organization_dashboard(self):
        user = UserFactory.create()
        org = OrganizationFactory.create()

        view = org_views.OrganizationEdit.as_view()

        request = HttpRequest()
        request.META['HTTP_REFERER'] = '/account/login/'
        setattr(request, 'user', user)
        setattr(request, 'method', 'GET')

        setattr(request, 'session', 'session')
        self.messages = FallbackStorage(request)
        setattr(request, '_messages', self.messages)

        kwargs = {'slug': org.slug}

        exp_redirect = reverse('organization:dashboard', kwargs=kwargs)
        response = view(request, **kwargs)
        assert response.status_code == 302
        assert exp_redirect == response['location']
Example #27
0
 def _test_create_private_record(
     self,
     status,  # Expected HTTP status status_code
     user=None,  # Optional user that does the update
     count=None,  # Expected number of records in DB
     make_org_member=False,  # Flag to make the user an org member
     make_other_org_member=False  # Flag to make the user a member
     # of another org
 ):
     if user is None:
         user = self.user
     org, prj = self._test_objs(access="private")
     if make_org_member:
         OrganizationRole.objects.create(organization=org, user=user)
     if make_other_org_member:
         other_org = OrganizationFactory.create()
         OrganizationRole.objects.create(organization=other_org, user=user)
     content = self._post(
         org_slug=org.slug, prj_slug=prj.slug, user=user, status=status, data=self.default_create_data
     )
     if status == status_code.HTTP_403_FORBIDDEN:
         assert content["detail"] == PermissionDenied.default_detail
Example #28
0
 def _test_list_private_record(
     self,
     status=None,  # Optional expected HTTP status status_code
     user=None,  # Optional user that does the update
     length=None,  # Expected number of records returned
     make_org_member=False,  # Flag to make the user an org member
     make_other_org_member=False  # Flag to make the user a member
     # of another org
 ):
     if user is None:
         user = self.user
     org, prj = self._test_objs(access="private")
     if make_org_member:
         OrganizationRole.objects.create(organization=org, user=user)
     if make_other_org_member:
         other_org = OrganizationFactory.create()
         OrganizationRole.objects.create(organization=other_org, user=user)
     if status == status_code.HTTP_200_OK and length is None:
         length = self.num_records
     content = self._get(org_slug=org.slug, prj_slug=prj.slug, user=user, status=status, length=length)
     if status == status_code.HTTP_403_FORBIDDEN:
         assert content["detail"] == PermissionDenied.default_detail
Example #29
0
    def _test_delete_private_record(
        self,
        status,  # Expected HTTP status status_code
        user=None,  # Optional user that does the update
        make_org_member=False,  # Flag to make the user an org member
        make_org_admin=False,  # Flag to make the user an org admin
        make_other_org_member=False  # Flag to make the user a member
        # of another org
    ):
        # Set up request
        existing_record, org = self._test_objs(access="private")
        if user is None:
            user = self.user
        if make_org_member:
            OrganizationRole.objects.create(organization=org, user=user)
        if make_org_admin:
            OrganizationRole.objects.create(organization=org, user=user, admin=True)
        if make_other_org_member:
            other_org = OrganizationFactory.create()
            OrganizationRole.objects.create(organization=other_org, user=user)

        kwargs = {
            "org_slug": org.slug,
            "prj_slug": existing_record.project.slug,
            "record_id": existing_record.id,
            "user": user,
        }

        # Perform request
        content = self._delete(status=status, **kwargs)

        # Perform post-checks
        kwargs["user"] = self.user
        if status == status_code.HTTP_204_NO_CONTENT:
            self._get(status=status_code.HTTP_404_NOT_FOUND, **kwargs)
        if status == status_code.HTTP_403_FORBIDDEN:
            assert content["detail"] == PermissionDenied.default_detail
            self._get(status=status_code.HTTP_200_OK, **kwargs)
 def setup_models(self):
     self.user = UserFactory.create()
     assign_policies(self.user)
     self.org = OrganizationFactory.create()
     self.prj = ProjectFactory.create(
         organization=self.org, add_users=[self.user])
 def setup_models(self):
     self.user = UserFactory.create()
     assign_policies(self.user)
     self.org = OrganizationFactory.create()
     self.prj = ProjectFactory.create(
         organization=self.org, add_users=[self.user])
 def setup_models(self):
     self.user = UserFactory.create()
     self.org = OrganizationFactory.create()
     self.prj = ProjectFactory.create(organization=self.org)
     self.superuser_role = Role.objects.get(name='superuser')
Example #33
0
    def setup_models(self):
        self.user = UserFactory.create()
        self.org = OrganizationFactory.create()
        self.prj = ProjectFactory.create(organization=self.org)
        self.prj_2 = ProjectFactory.create(organization=self.org)
        self.prj_3 = ProjectFactory.create(organization=self.org)

        OrganizationRole.objects.create(
            organization=self.org, user=self.user, admin=True)

        QuestionnaireFactory.create(
            project=self.prj,
            xls_form=get_form('test_standard_questionnaire'),
            filename='test_standard_questionnaire',
            id_string='test_standard_questionnaire',
            version=20160727122110)

        questionnaire = QuestionnaireFactory.create(
            project=self.prj_2,
            xls_form=get_form('test_standard_questionnaire_2'),
            filename='test_standard_questionnaire_2',
            id_string='test_standard_questionnaire_2',
            version=20160727122111)

        QuestionFactory.create(
            name='location_geometry',
            label='Location of Parcel',
            type='GS',
            questionnaire=questionnaire)

        QuestionnaireFactory.create(
            project=self.prj_3,
            xls_form=get_form('test_standard_questionnaire_bad'),
            filename='test_standard_questionnaire_bad',
            id_string='test_standard_questionnaire_bad',
            version=20160727122112)

        # project 1
        create_attrs_schema(
            project=self.prj, dict=default_party_xform_group,
            content_type=ContentType.objects.get(
                app_label='party', model='party'), errors=[])
        create_attrs_schema(
            project=self.prj, dict=individual_party_xform_group,
            content_type=ContentType.objects.get(
                app_label='party', model='party'), errors=[])
        create_attrs_schema(
            project=self.prj, dict=location_xform_group,
            content_type=ContentType.objects.get(
                app_label='spatial', model='spatialunit'), errors=[])
        create_attrs_schema(
            project=self.prj, dict=tenure_relationship_xform_group,
            content_type=ContentType.objects.get(
                app_label='party', model='tenurerelationship'), errors=[])

        # project 2
        create_attrs_schema(
            project=self.prj_2, dict=default_party_xform_group,
            content_type=ContentType.objects.get(
                app_label='party', model='party'), errors=[])
        create_attrs_schema(
            project=self.prj_2, dict=individual_party_xform_group,
            content_type=ContentType.objects.get(
                app_label='party', model='party'), errors=[])
        create_attrs_schema(
            project=self.prj_2, dict=location_xform_group,
            content_type=ContentType.objects.get(
                app_label='spatial', model='spatialunit'), errors=[])
        create_attrs_schema(
            project=self.prj_2, dict=tenure_relationship_xform_group,
            content_type=ContentType.objects.get(
                app_label='party', model='tenurerelationship'), errors=[])
Example #34
0
 def setup_models(self):
     self.user = UserFactory.create()
     self.org = OrganizationFactory.create()
     self.prj = ProjectFactory.create(organization=self.org)
     self.superuser_role = Role.objects.get(name='superuser')