def setUp(self):
        super().setUp()
        PolicyFactory.load_policies()
        create_attribute_types()

        loadattrtypes.Command().handle(force=True)
        load_tenure_relationship_types(force=True)

        self.user = UserFactory.create()
        self.project = ProjectFactory.create(current_questionnaire='a1')

        self.questionnaire = QuestionnaireFactory.create(id_string='a1',
                                                         version=0,
                                                         project=self.project,
                                                         id='a1')
        QuestionFactory.create(name='location_geometry',
                               label='Location of Parcel',
                               type='GS',
                               questionnaire=self.questionnaire)

        content_type_party = ContentType.objects.get(app_label='party',
                                                     model='party')
        content_type_spatial = ContentType.objects.get(app_label='spatial',
                                                       model='spatialunit')
        content_type_tenure = ContentType.objects.get(
            app_label='party', model='tenurerelationship')
        for content_type in [
                content_type_party, content_type_tenure, content_type_spatial
        ]:
            schema = Schema.objects.create(
                content_type=content_type,
                selectors=(self.project.organization.id, self.project.id,
                           'a1'))
            attr_type = AttributeType.objects.get(name='boolean')
            Attribute.objects.create(schema=schema,
                                     name='fname',
                                     long_name='True or False',
                                     attr_type=attr_type,
                                     index=0,
                                     required=False,
                                     omit=False)
            attr_type = AttributeType.objects.get(name='text')
            Attribute.objects.create(schema=schema,
                                     name='fname_two',
                                     long_name='Notes',
                                     attr_type=attr_type,
                                     index=1,
                                     required=False,
                                     omit=False)

        OrganizationRole.objects.create(user=self.user,
                                        organization=self.project.organization)
Пример #2
0
    def handle(self, *args, **options):
        # All of the following are idempotent unless "force" is used.
        if options['force']:
            print('FORCING STATIC DATA RELOAD!!!\n')

        print('LOADING SITE\n')
        loadsite.Command().handle(force=options['force'])
        print('LOADING COUNTRIES\n')
        loadcountries.Command().handle(force=options['force'])
        print('LOADING POLICIES\n')
        loadpolicies.Command().handle(force=options['force'])
        print('LOADING ATTRIBUTE TYPES\n')
        loadattrtypes.Command().handle(force=options['force'])
Пример #3
0
    def handle(self, *args, **options):
        if options['update_policies']:
            print('PERFORMING POLICY UPDATE FROM FILES!!!\n')
            loadpolicies.Command().handle(force=False, update=True)
        else:
            # All of the following are idempotent unless "force" is used.
            if options['force']:
                print('FORCING STATIC DATA RELOAD!!!\n')

            print('LOADING SITE\n')
            loadsite.Command().handle(force=options['force'])
            print('LOADING COUNTRIES\n')
            loadcountries.Command().handle(force=options['force'])
            print('LOADING POLICIES\n')
            loadpolicies.Command().handle(force=options['force'], update=False)
            print('LOADING ATTRIBUTE TYPES\n')
            loadattrtypes.Command().handle(force=options['force'])
            print('LOADING TENURE RELATIONSHIP TYPES\n')
            loadtenurereltypes.Command().handle(force=options['force'])