Skip to content

Commit

Permalink
fix: query preset removing a quick preset does not remove preset (#1165
Browse files Browse the repository at this point in the history
…) (#1458)
  • Loading branch information
stolpeo authored Mar 19, 2024
1 parent 6bc5bfb commit e90e3a1
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 94 deletions.
243 changes: 155 additions & 88 deletions variants/urls/presets.py
Original file line number Diff line number Diff line change
@@ -1,95 +1,162 @@
"""Presets-related urls."""

from itertools import chain

from django.conf.urls import url

import variants.views.ajax.presets as views_ajax

_entity_names = [
"FrequencyPresets",
"FlagsEtcPresets",
"ImpactPresets",
"QualityPresets",
"ChromosomePresets",
presets_ajax_urlpatterns = [
###################################
### "Regular" PresetSet members ###
###################################
# FrequencyPresets
url(
regex=r"^ajax/frequencypresets/list-create/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.FrequencyPresetsListCreateAjaxView.as_view(),
name="ajax-frequencypresets-listcreate",
),
url(
regex=r"^ajax/frequencypresets/retrieve-update-destroy/(?P<frequencypresets>[0-9a-f-]+)/?$",
view=views_ajax.FrequencyPresetsRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-frequencypresets-retrieveupdatedestroy",
),
url(
regex=r"^ajax/frequencypresets/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/?$",
view=views_ajax.FrequencyPresetsCloneFactoryPresetsAjaxView.as_view(),
name="ajax-frequencypresets-clonefactorypresets",
),
url(
regex=r"ajax/frequencypresets/clone-other/(?P<frequencypresets>[0-9a-f-]+)/?$",
view=views_ajax.FrequencyPresetsCloneOtherAjaxView.as_view(),
name="ajax-frequencypresets-cloneother",
),
# FlagsEtcPresets
url(
regex=r"^ajax/flagsetcpresets/list-create/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.FlagsEtcPresetsListCreateAjaxView.as_view(),
name="ajax-flagsetcpresets-listcreate",
),
url(
regex=r"^ajax/flagsetcpresets/retrieve-update-destroy/(?P<flagsetcpresets>[0-9a-f-]+)/?$",
view=views_ajax.FlagsEtcPresetsRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-flagsetcpresets-retrieveupdatedestroy",
),
url(
regex=r"^ajax/flagsetcpresets/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/?$",
view=views_ajax.FlagsEtcPresetsCloneFactoryPresetsAjaxView.as_view(),
name="ajax-flagsetcpresets-clonefactorypresets",
),
url(
regex=r"ajax/flagsetcpresets/clone-other/(?P<flagsetcpresets>[0-9a-f-]+)/?$",
view=views_ajax.FlagsEtcPresetsCloneOtherAjaxView.as_view(),
name="ajax-flagsetcpresets-cloneother",
),
# ImpactPresets
url(
regex=r"^ajax/impactpresets/list-create/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.ImpactPresetsListCreateAjaxView.as_view(),
name="ajax-impactpresets-listcreate",
),
url(
regex=r"^ajax/impactpresets/retrieve-update-destroy/(?P<impactpresets>[0-9a-f-]+)/?$",
view=views_ajax.ImpactPresetsRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-impactpresets-retrieveupdatedestroy",
),
url(
regex=r"^ajax/impactpresets/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/?$",
view=views_ajax.ImpactPresetsCloneFactoryPresetsAjaxView.as_view(),
name="ajax-impactpresets-clonefactorypresets",
),
url(
regex=r"ajax/impactpresets/clone-other/(?P<impactpresets>[0-9a-f-]+)/?$",
view=views_ajax.ImpactPresetsCloneOtherAjaxView.as_view(),
name="ajax-impactpresets-cloneother",
),
# QualityPresets
url(
regex=r"^ajax/qualitypresets/list-create/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.QualityPresetsListCreateAjaxView.as_view(),
name="ajax-qualitypresets-listcreate",
),
url(
regex=r"^ajax/qualitypresets/retrieve-update-destroy/(?P<qualitypresets>[0-9a-f-]+)/?$",
view=views_ajax.QualityPresetsRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-qualitypresets-retrieveupdatedestroy",
),
url(
regex=r"^ajax/qualitypresets/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/?$",
view=views_ajax.QualityPresetsCloneFactoryPresetsAjaxView.as_view(),
name="ajax-qualitypresets-clonefactorypresets",
),
url(
regex=r"ajax/qualitypresets/clone-other/(?P<qualitypresets>[0-9a-f-]+)/?$",
view=views_ajax.QualityPresetsCloneOtherAjaxView.as_view(),
name="ajax-qualitypresets-cloneother",
),
# ChromosomePresets
url(
regex=r"^ajax/chromosomepresets/list-create/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.ChromosomePresetsListCreateAjaxView.as_view(),
name="ajax-chromosomepresets-listcreate",
),
url(
regex=r"^ajax/chromosomepresets/retrieve-update-destroy/(?P<chromosomepresets>[0-9a-f-]+)/?$",
view=views_ajax.ChromosomePresetsRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-chromosomepresets-retrieveupdatedestroy",
),
url(
regex=r"^ajax/chromosomepresets/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/?$",
view=views_ajax.ChromosomePresetsCloneFactoryPresetsAjaxView.as_view(),
name="ajax-chromosomepresets-clonefactorypresets",
),
url(
regex=r"ajax/chromosomepresets/clone-other/(?P<chromosomepresets>[0-9a-f-]+)/?$",
view=views_ajax.ChromosomePresetsCloneOtherAjaxView.as_view(),
name="ajax-chromosomepresets-cloneother",
),
#############################################
### Quick Presets (only clone from other) ###
#############################################
url(
regex=r"^ajax/quickpresets/list-create/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.QuickPresetsListCreateAjaxView.as_view(),
name="ajax-quickpresets-listcreate",
),
url(
regex=r"^ajax/quickpresets/retrieve-update-destroy/(?P<quickpresets>[0-9a-f-]+)/?$",
view=views_ajax.QuickPresetsRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-quickpresets-retrieveupdatedestroy",
),
url(
regex=r"^ajax/quickpresets/clone-other/(?P<quickpresets>[0-9a-f-]+)/?$",
view=views_ajax.QuickPresetsCloneOtherAjaxView.as_view(),
name="ajax-quickpresets-cloneother",
),
#################
### PresetSet ###
#################
url(
regex=r"^ajax/presetset/list/?$",
view=views_ajax.PresetSetListAllAjaxView.as_view(),
name="ajax-presetset-listall",
),
url(
regex=r"^ajax/presetset/list-create/(?P<project>[0-9a-f-]+)/?$",
view=views_ajax.PresetSetListCreateAjaxView.as_view(),
name="ajax-presetset-listcreate",
),
url(
regex=r"^ajax/presetset/retrieve-update-destroy/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.PresetSetRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-presetset-retrieveupdatedestroy",
),
url(
regex=r"^ajax/presetset/clone-factory-presets/?$",
view=views_ajax.PresetSetCloneFactoryPresetsAjaxView.as_view(),
name="ajax-presetset-clonefactorypresets",
),
url(
regex=r"^ajax/presetset/clone-other/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.PresetSetCloneOtherAjaxView.as_view(),
name="ajax-presetset-cloneother",
),
]


def _create_urlpatterns(name):
lower = name.lower()
return [
url(
regex=rf"ajax/{lower}/list-create/(?P<presetset>[0-9a-f-]+)/?",
view=getattr(views_ajax, f"{name}ListCreateAjaxView").as_view(),
name=f"ajax-{lower}-listcreate",
),
url(
regex=rf"ajax/{lower}/retrieve-update-destroy/(?P<{lower}>[0-9a-f-]+)/?",
view=getattr(views_ajax, f"{name}RetrieveUpdateDestroyAjaxView").as_view(),
name=f"ajax-{lower}-retrieveupdatedestroy",
),
url(
regex=rf"ajax/{lower}/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/?",
view=getattr(views_ajax, f"{name}CloneFactoryPresetsAjaxView").as_view(),
name=f"ajax-{lower}-clonefactorypresets",
),
url(
regex=rf"ajax/{lower}/clone-other/(?P<{lower}>[0-9a-f-]+)/?",
view=getattr(views_ajax, f"{name}CloneOtherAjaxView").as_view(),
name=f"ajax-{lower}-cloneother",
),
]


_presets_ajax_urlpatterns = [
# "Regular" PresetSet members
list(map(_create_urlpatterns, _entity_names))
+ [
[
# Quick Presets (only clone from other)
url(
regex=r"^ajax/quickpresets/list-create/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.QuickPresetsListCreateAjaxView.as_view(),
name="ajax-quickpresets-listcreate",
),
url(
regex=r"^ajax/quickpresets/retrieve-update-destroy/(?P<quickpresets>[0-9a-f-]+)/?$",
view=views_ajax.QuickPresetsRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-quickpresets-retrieveupdatedestroy",
),
url(
regex=r"^ajax/quickpresets/clone-other/(?P<quickpresets>[0-9a-f-]+)/?$",
view=views_ajax.QuickPresetsCloneOtherAjaxView.as_view(),
name="ajax-quickpresets-cloneother",
),
# PresetSet
url(
regex=r"^ajax/presetset/list/?$",
view=views_ajax.PresetSetListAllAjaxView.as_view(),
name="ajax-presetset-listall",
),
url(
regex=r"^ajax/presetset/list-create/(?P<project>[0-9a-f-]+)/?$",
view=views_ajax.PresetSetListCreateAjaxView.as_view(),
name="ajax-presetset-listcreate",
),
url(
regex=r"^ajax/presetset/retrieve-update-destroy/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.PresetSetRetrieveUpdateDestroyAjaxView.as_view(),
name="ajax-presetset-retrieveupdatedestroy",
),
url(
regex=r"^ajax/presetset/clone-factory-presets/?$",
view=views_ajax.PresetSetCloneFactoryPresetsAjaxView.as_view(),
name="ajax-presetset-clonefactorypresets",
),
url(
regex=r"^ajax/presetset/clone-other/(?P<presetset>[0-9a-f-]+)/?$",
view=views_ajax.PresetSetCloneOtherAjaxView.as_view(),
name="ajax-presetset-cloneother",
),
]
]
]

presets_ajax_urlpatterns = list(chain(*chain(*_presets_ajax_urlpatterns)))
12 changes: 6 additions & 6 deletions variants/vueapp/src/stores/queryPresets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,22 +511,22 @@ export const useQueryPresetsStore = defineStore('queryPresets', () => {
try {
switch (category) {
case 'quickpresets':
await queryPresetsClient.destroyQuickPresets(presetSetUuid)
await queryPresetsClient.destroyQuickPresets(presetsUuid)
break
case 'frequencypresets':
await queryPresetsClient.destroyFrequencyPresets(presetSetUuid)
await queryPresetsClient.destroyFrequencyPresets(presetsUuid)
break
case 'impactpresets':
await queryPresetsClient.destroyImpactPresets(presetSetUuid)
await queryPresetsClient.destroyImpactPresets(presetsUuid)
break
case 'chromosomepresets':
await queryPresetsClient.destroyChromosomePresets(presetSetUuid)
await queryPresetsClient.destroyChromosomePresets(presetsUuid)
break
case 'qualitypresets':
await queryPresetsClient.destroyQualityPresets(presetSetUuid)
await queryPresetsClient.destroyQualityPresets(presetsUuid)
break
case 'flagsetcpresets':
await queryPresetsClient.destroyFlagsEtcPresets(presetSetUuid)
await queryPresetsClient.destroyFlagsEtcPresets(presetsUuid)
break
default:
console.error(`Invalid category: ${category}`)
Expand Down

0 comments on commit e90e3a1

Please sign in to comment.