diff --git a/backend/seqvars/models/base.py b/backend/seqvars/models/base.py index c57d57871..0ddf925cc 100644 --- a/backend/seqvars/models/base.py +++ b/backend/seqvars/models/base.py @@ -613,6 +613,7 @@ def clone_with_presetsset( # First, handle the "normal" presets categories. A side-effect of the # code below is that the UUIDs of the presets are changed and we rely # on this when createing the predefined queries. + uuid_old_to_new = {} for key in ( "seqvarsquerypresetsfrequency_set", "seqvarsquerypresetsvariantprio_set", @@ -628,6 +629,7 @@ def clone_with_presetsset( obj.id = None obj._state.adding = True new_uuid = uuid_object.uuid4() + uuid_old_to_new[obj.sodar_uuid] = new_uuid obj.sodar_uuid = new_uuid obj.presetssetversion = result obj.save() @@ -640,28 +642,28 @@ def clone_with_presetsset( obj.sodar_uuid = uuid_object.uuid4() obj.presetssetversion = result obj.quality = SeqvarsQueryPresetsQuality.objects.get( - sodar_uuid=obj.quality.sodar_uuid, + sodar_uuid=uuid_old_to_new[obj.quality.sodar_uuid], ) obj.frequency = SeqvarsQueryPresetsFrequency.objects.get( - sodar_uuid=obj.frequency.sodar_uuid, + sodar_uuid=uuid_old_to_new[obj.frequency.sodar_uuid], ) obj.consequence = SeqvarsQueryPresetsConsequence.objects.get( - sodar_uuid=obj.consequence.sodar_uuid, + sodar_uuid=uuid_old_to_new[obj.consequence.sodar_uuid], ) obj.locus = SeqvarsQueryPresetsLocus.objects.get( - sodar_uuid=obj.locus.sodar_uuid, + sodar_uuid=uuid_old_to_new[obj.locus.sodar_uuid], ) obj.phenotypeprio = SeqvarsQueryPresetsPhenotypePrio.objects.get( - sodar_uuid=obj.phenotypeprio.sodar_uuid, + sodar_uuid=uuid_old_to_new[obj.phenotypeprio.sodar_uuid], ) obj.variantprio = SeqvarsQueryPresetsVariantPrio.objects.get( - sodar_uuid=obj.variantprio.sodar_uuid, + sodar_uuid=uuid_old_to_new[obj.variantprio.sodar_uuid], ) obj.clinvar = SeqvarsQueryPresetsClinvar.objects.get( - sodar_uuid=obj.clinvar.sodar_uuid, + sodar_uuid=uuid_old_to_new[obj.clinvar.sodar_uuid], ) obj.columns = SeqvarsQueryPresetsColumns.objects.get( - sodar_uuid=obj.columns.sodar_uuid, + sodar_uuid=uuid_old_to_new[obj.columns.sodar_uuid], ) obj.save() diff --git a/backend/seqvars/tests/test_models.py b/backend/seqvars/tests/test_models.py index 2d2ad35ce..79c08ad5d 100644 --- a/backend/seqvars/tests/test_models.py +++ b/backend/seqvars/tests/test_models.py @@ -126,6 +126,7 @@ def test_clone_factory_default(self): # Note: only smoke test implemented so far. project = ProjectFactory() querypresetset = create_seqvarspresetsset_short_read_genome() + querypresetset.save() querypresetset.clone_with_latest_version(project=project) diff --git a/backend/seqvars/tests/test_permissions_api.py b/backend/seqvars/tests/test_permissions_api.py index cf1b6acf9..86470ea4b 100644 --- a/backend/seqvars/tests/test_permissions_api.py +++ b/backend/seqvars/tests/test_permissions_api.py @@ -2134,6 +2134,7 @@ def cleanup(): def test_create_from(self): # TODO: change after https://github.com/varfish-org/varfish-server/issues/1920 presetsset_factory = create_seqvarspresetsset_short_read_exome_legacy() + presetsset_factory.save() presetsset = presetsset_factory.clone_with_latest_version(project=self.project) version = presetsset.versions.all()[0] predefinedquery = version.seqvarspredefinedquery_set.all()[0] diff --git a/backend/seqvars/tests/test_views_api.py b/backend/seqvars/tests/test_views_api.py index ee3d09314..a0db57bd1 100644 --- a/backend/seqvars/tests/test_views_api.py +++ b/backend/seqvars/tests/test_views_api.py @@ -2033,6 +2033,7 @@ def test_create_from(self): with self.login(self.superuser): # TODO: change after https://github.com/varfish-org/varfish-server/issues/1920 presetsset_factory = create_seqvarspresetsset_short_read_exome_legacy() + presetsset_factory.save() presetsset = presetsset_factory.clone_with_latest_version(project=self.project) version = presetsset.versions.all()[0] predefinedquery = version.seqvarspredefinedquery_set.all()[0] diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 9600e90e9..ecfe88905 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -32,6 +32,7 @@ "jquery": "^3.7.1", "lodash.debounce": "^4.0.8", "luxon": "^3.5.0", + "object-deep-merge": "^1.0.4", "pinia": "^2.2.2", "plotly.js-dist": "^2.34.0", "remeda": "^2.6.0", @@ -18387,6 +18388,27 @@ "node": ">=0.10.0" } }, + "node_modules/object-deep-merge": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/object-deep-merge/-/object-deep-merge-1.0.4.tgz", + "integrity": "sha512-5LDJe4vuj1jfm+gBo2ze4ERPsDGfRARz7OcPFY+Qr6b90J+D+DvBPRMTAGmd8IB+V9mpU1TARJwBODFeNP9Xpw==", + "license": "MIT", + "dependencies": { + "type-fest": "4.2.0" + } + }, + "node_modules/object-deep-merge/node_modules/type-fest": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.2.0.tgz", + "integrity": "sha512-5zknd7Dss75pMSED270A1RQS3KloqRJA9XbXLe0eCxyw7xXFb3rd+9B0UQ/0E+LQT6lnrLviEolYORlRWamn4w==", + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/object-inspect": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index 7ef25480a..5e6a33ed9 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -40,6 +40,7 @@ "jquery": "^3.7.1", "lodash.debounce": "^4.0.8", "luxon": "^3.5.0", + "object-deep-merge": "^1.0.4", "pinia": "^2.2.2", "plotly.js-dist": "^2.34.0", "remeda": "^2.6.0", diff --git a/frontend/src/seqvars/components/PresetsEditor/CategoryPresetsClinvarEditor.vue b/frontend/src/seqvars/components/PresetsEditor/CategoryPresetsClinvarEditor.vue index a10d916a3..6ad7931d7 100644 --- a/frontend/src/seqvars/components/PresetsEditor/CategoryPresetsClinvarEditor.vue +++ b/frontend/src/seqvars/components/PresetsEditor/CategoryPresetsClinvarEditor.vue @@ -1,18 +1,25 @@ diff --git a/frontend/src/seqvars/components/PresetsEditor/CategoryPresetsColumnsEditor.vue b/frontend/src/seqvars/components/PresetsEditor/CategoryPresetsColumnsEditor.vue index dba0470e0..b739fafac 100644 --- a/frontend/src/seqvars/components/PresetsEditor/CategoryPresetsColumnsEditor.vue +++ b/frontend/src/seqvars/components/PresetsEditor/CategoryPresetsColumnsEditor.vue @@ -1,18 +1,25 @@