Skip to content

Commit

Permalink
🐛 [#2284] Remove hardcoded CMS app namespace for selected categories
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Apr 25, 2024
1 parent cecdb72 commit 5b54788
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/open_inwoner/cms/products/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.urls import NoReverseMatch, resolve, reverse
from django.utils.translation import gettext_lazy as _

from cms.apphook_pool import apphook_pool
Expand All @@ -14,7 +15,16 @@

def selected_categories_enabled() -> bool:
profile_app = apphook_pool.get_apphook("ProfileApphook")
config = profile_app.get_config("profile")

# retrieve namespace of ProfileConfig instance that's being used
try:
categories_resolver = resolve(reverse("profile:categories"))
except NoReverseMatch:
return False

profile_namespace = categories_resolver.namespace
config = profile_app.get_config(profile_namespace)

if config:
return config.selected_categories
return False
Expand Down

0 comments on commit 5b54788

Please sign in to comment.