Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [#2284] Remove hardcoded CMS app namespace for selected categories #1179

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading