-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Allow overriding the base queryset to be used in Snippets IndexView #10275
Conversation
Manage this branch in SquashTest this branch here: https://laymonagecustom-snippets-get-q-egkin.squash.io |
44ed0b4
to
0b7b7a7
Compare
0b7b7a7
to
68d113a
Compare
68d113a
to
879a0a7
Compare
…tml and index_results.html
…ets ModelIndexView
…late_name to be a list
…et.get_queryset()
…accessing the viewset directly
879a0a7
to
4add057
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
@@ -22,20 +22,27 @@ | |||
from wagtail.test.utils import WagtailTestUtils | |||
|
|||
|
|||
class TestCustomIcon(WagtailTestUtils, TestCase): | |||
class BaseSnippetViewSetTests(WagtailTestUtils, TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this encompasses the search tests that now have to be done as a TransactionTestCase instead as of #10208 - will find out when I rebase... - but if it does, I think the work needed to untangle that might outweigh the benefit of pulling out these methods, in which case I might skip this commit.
Merged in fbd3cca |
Part of wagtail/rfcs#85. Incorporates #10271.
This PR extracts a
get_base_queryset()
method to the genericIndexView
(inspired by ModelAdmin'sWMABaseView.get_base_queryset()
for the initial logic of the queryset, before any filters or search are applied. The API is surfaced inSnippetViewSet
asget_queryset(request)
to mirrorModelAdmin.get_queryset(request)
API. On the SnippetsIndexView.get_base_queryset()
, we first try to callSnippetViewSet.get_queryset(self.request)
. If the result isNone
(the default), the original implementation in the genericIndexView
is used.Please check the following:
make lint
from the Wagtail root.Please describe additional details for testing this change.
Continuing the test example in #10256:
If you create a Person object with a job title that contains
[HIDDEN]
, it won't be shown on the listing view.Footnotes
Development Testing ↩