Skip to content

Commit

Permalink
Merge pull request #1179 from maykinmedia/fix/2284-incorrect-apphook-…
Browse files Browse the repository at this point in the history
…namespace

🐛 [#2284] Remove hardcoded CMS app namespace for selected categories
  • Loading branch information
alextreme authored Apr 25, 2024
2 parents b0e7070 + 5b54788 commit 532540a
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 532540a

Please sign in to comment.