8000 fix: Remove `Page` object from admin index (introduced by #7995) by fsbraun · Pull Request #8066 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: Remove Page object from admin index (introduced by #7995) #8066

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 8 commits into from
Dec 5, 2024
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
3 changes: 3 additions & 0 deletions cms/admin/pageadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class PageAdmin(admin.ModelAdmin):
inlines = PERMISSION_ADMIN_INLINES
search_fields = ('=id', 'urls__slug', 'pagecontent_set__title', 'reverse_id')

def has_module_permission(self, request):
return False # Hides page model from the admin index

def has_add_permission(self, request):
return False

Expand Down
13 changes: 13 additions & 0 deletions cms/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,19 @@ def get_permless(self):
def get_page(self):
return self.page

def test_admin_index(self):
endpoint = admin_reverse("index")
endpoint_page = admin_reverse("cms_page_changelist")
endpoint_page_content = admin_reverse("cms_pagecontent_changelist")

admin_user = self.get_admin()
with self.login_user_context(admin_user):
response = self.client.get(endpoint)
self.assertEqual(response.status_code, 200)

self.assertNotContains(response, endpoint_page)
self.assertContains(response, endpoint_page_content)

def test_change_innavigation(self):
page = self.get_page()
content = self.get_pagecontent_obj(page, 'en')
Expand Down
Loading
0