Overwrite default sort ordering in CMS Pages overview
This commit is contained in:
parent
bbaa5882e0
commit
8dd865ae97
|
|
@ -11,7 +11,7 @@ from wagtail.documents import urls as wagtaildocs_urls
|
|||
from wagtailautocomplete.urls.admin import urlpatterns as autocomplete_admin_urls
|
||||
|
||||
from core import views
|
||||
|
||||
from core.views import override_wagtailadmin_explore_default_ordering
|
||||
|
||||
urlpatterns = [
|
||||
# django admin
|
||||
|
|
@ -20,6 +20,7 @@ urlpatterns = [
|
|||
|
||||
# wagtail
|
||||
url(r'^admin/autocomplete/', include(autocomplete_admin_urls)),
|
||||
re_path(r'^cms/pages/(\d+)/$', override_wagtailadmin_explore_default_ordering),
|
||||
url(r'^cms/', include(wagtailadmin_urls)),
|
||||
url(r'^documents/', include(wagtaildocs_urls)),
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import requests
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http.response import HttpResponse
|
||||
from django.http.response import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import render
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.views.generic import TemplateView
|
||||
from graphene_django.views import GraphQLView
|
||||
from wagtail.admin.views.pages.listing import index as wagtailadmin_explore
|
||||
|
||||
|
||||
class PrivateGraphQLView(LoginRequiredMixin, GraphQLView):
|
||||
|
|
@ -24,3 +25,17 @@ def home(request):
|
|||
print('Can not connect to dev server at http://localhost:8080:', e)
|
||||
|
||||
return render(request, 'index.html', {})
|
||||
|
||||
|
||||
def override_wagtailadmin_explore_default_ordering(request, parent_page_id):
|
||||
"""
|
||||
Wrap Wagtail's explore view to change the default ordering
|
||||
"""
|
||||
if request.method == 'GET' and 'ordering' not in request.GET:
|
||||
|
||||
# Display reordering handles by default for children of FooPage types.
|
||||
#if FooPage.objects.filter(id=parent_page_id).first():
|
||||
return HttpResponseRedirect(request.path_info + '?ordering=ord')
|
||||
|
||||
|
||||
return wagtailadmin_explore(request, parent_page_id=parent_page_id)
|
||||
|
|
|
|||
Loading…
Reference in New Issue