8000 fix: preserve `view_class` in decorated views by Will-Hoey · Pull Request #7664 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: preserve view_class in decorated views #7664

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

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cms/tests/test_apphooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from cms.test_utils.testcases import CMSTestCase
from cms.tests.test_menu_utils import DumbPageLanguageUrl
from cms.toolbar.toolbar import CMSToolbar
from cms.utils.compat import DJANGO_2_2, DJANGO_3
from cms.utils.compat import DJANGO_2_2, DJANGO_3, DJANGO_4_1
from cms.utils.conf import get_cms_setting
from cms.utils.urlutils import admin_reverse
from menus.menu_pool import menu_pool
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_apphook_permissions_preserves_view_name(self):
view_names = (
('sample-settings', 'sample_view'),
('sample-class-view', 'ClassView'),
('sample-class-based-view', 'view' if not (DJANGO_3 or DJANGO_2_2) else 'ClassBasedView' ),
('sample-class-based-view', 'ClassBasedView' ),
)

with force_language("en"):
Expand Down
2 changes: 2 additions & 0 deletions cms/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def inner(request, *args, **kwargs):
return func(request, *args, **kwargs)
inner.__module__ = func.__module__
inner.__doc__ = func.__doc__
if hasattr(func, "view_class"):
inner.view_class = func.view_class
if hasattr(func, '__name__'):
inner.__name__ = func.__name__
elif hasattr(func, '__class__'):
Expand Down
0