Skip to content

Commit

Permalink
Set usage_url_name explicitly on pages.UsageView
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage authored and lb- committed Mar 13, 2024
1 parent 2ee27d4 commit c844c54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions wagtail/admin/tests/pages/test_page_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,16 @@ def test_has_editable_usage(self):
)
self.assertContains(response, "Thank you redirect page")
self.assertContains(response, "<td>Form page with redirect</td>", html=True)

def test_pagination(self):
for _ in range(50):
PageChooserModel.objects.create(page=self.page)

usage_url = reverse("wagtailadmin_pages:usage", args=(self.page.id,))
response = self.client.get(f"{usage_url}?p=2")

self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/generic/listing.html")
self.assertContains(response, "Page 2 of 3.")
self.assertContains(response, f"{usage_url}?p=1")
self.assertContains(response, f"{usage_url}?p=3")
1 change: 1 addition & 0 deletions wagtail/admin/views/pages/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class UsageView(generic.UsageView):
model = Page
pk_url_kwarg = "page_id"
header_icon = "doc-empty-inverse"
usage_url_name = "wagtailadmin_pages:usage"

def dispatch(self, request, *args, **kwargs):
if not self.object.permissions_for_user(request.user).can_edit():
Expand Down

0 comments on commit c844c54

Please sign in to comment.