Exemple #1
0
 def save_object(self, obj, **kwargs):
     request_user = self.context['request'].user
     errors = SourceVersion.persist_new(obj, user=request_user, **kwargs)
     if errors:
         self._errors.update(errors)
     else:
         update_children_for_resource_version.delay(obj.id, 'source')
Exemple #2
0
 def save_object(self, obj, **kwargs):
     request_user = self.context['request'].user
     snap_serializer = CollectionDetailSerializer(kwargs['versioned_object'])
     snapshot_data = snap_serializer.data
     snapshot_data.pop('references')
     obj.collection_snapshot = snapshot_data
     errors = CollectionVersion.persist_new(obj, user=request_user, **kwargs)
     if errors:
         self._errors.update(errors)
     else:
         update_children_for_resource_version.delay(obj.id, 'collection')
Exemple #3
0
    def save_object(self, obj, **kwargs):
        with transaction.commit_on_success():
            request_user = self.context['request'].user
            snap_serializer = SourceDetailSerializer(kwargs['versioned_object'])
            obj.source_snapshot = snap_serializer.data
            errors = SourceVersion.persist_new(obj, user=request_user, **kwargs)
            if errors:
                self._errors.update(errors)

        if not errors:
         update_children_for_resource_version.delay(obj.id, 'source')
 def save_object(self, obj, **kwargs):
     with transaction.commit_on_success():
         request_user = self.context['request'].user
         snap_serializer = SourceDetailSerializer(kwargs['versioned_object'])
         obj.source_snapshot = snap_serializer.data
         obj.active_concepts = snap_serializer.data.get('active_concepts')
         obj.active_mappings = snap_serializer.data.get('active_mappings')
         errors = SourceVersion.persist_new(obj, user=request_user, **kwargs)
         if errors:
             self._errors.update(errors)
         else:
             update_children_for_resource_version.delay(obj.id, 'source')
Exemple #5
0
 def save_object(self, obj, **kwargs):
     request_user = self.context['request'].user
     snap_serializer = CollectionDetailSerializer(
         kwargs['versioned_object'])
     snapshot_data = snap_serializer.data
     snapshot_data.pop('references')
     obj.collection_snapshot = snapshot_data
     errors = CollectionVersion.persist_new(obj,
                                            user=request_user,
                                            **kwargs)
     if errors:
         self._errors.update(errors)
     else:
         update_children_for_resource_version.delay(obj.id, 'collection')
Exemple #6
0
    def handle(self, *args, **options):
        user = self.create_admin_user()

        version = 'v2019-07-01'

        source_version = SourceVersion.objects.filter(mnemonic=version)
        if source_version.exists():
            return

        org = self.create_organization(user, 'CIEL')

        source = self.create_source(user, org, 'CIEL')

        demo_file = open('./demo-data/ciel_' + version + '_c2k.json', 'rb')
        importer = ConceptsImporter(source,
                                    demo_file,
                                    user,
                                    OutputWrapper(sys.stdout),
                                    OutputWrapper(sys.stderr),
                                    save_validation_errors=False)
        importer.import_concepts(**options)

        demo_file = open('./demo-data/ciel_' + version + '_m2k.json', 'rb')
        importer = MappingsImporter(source, demo_file,
                                    OutputWrapper(sys.stdout),
                                    OutputWrapper(sys.stderr), user)
        importer.import_mappings(**options)

        new_version = SourceVersion.for_base_object(source,
                                                    version,
                                                    released=True)
        SourceVersion.persist_new(new_version,
                                  versioned_object=source,
                                  force_insert=True)
        update_children_for_resource_version.delay(new_version.id, 'source')

        export_source.delay(new_version.id)