Skip to content

Commit 641bcba

Browse files
committed
Remove renduntant changes
1 parent 4525bd7 commit 641bcba

File tree

3 files changed

+26
-34
lines changed

3 files changed

+26
-34
lines changed

example/example/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from search import views as search_views
1111

1212
urlpatterns = [
13-
url(r"", include(grapple_urls)),
1413
url(r"^django-admin/", admin.site.urls),
1514
url(r"^admin/", include(wagtailadmin_urls)),
1615
url(r"^documents/", include(wagtaildocs_urls)),
@@ -19,6 +18,7 @@
1918
# Wagtail's page serving mechanism. This should be the last pattern in
2019
# the list:
2120
url(r"", include(wagtail_urls)),
21+
url(r"", include(grapple_urls)),
2222
# Alternatively, if you want Wagtail pages to be served from a subpath
2323
# of your site, rather than the site root:
2424
# url(r'^pages/', include(wagtail_urls)),

grapple/types/pages.py

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -118,43 +118,38 @@ class Meta:
118118
interfaces = (PageInterface,)
119119

120120

121-
def get_specific_page(id, slug, url, token, content_type=None, info=None):
121+
def get_specific_page(id, slug, token, content_type=None, info=None):
122122
"""
123123
Get a spcecific page, also get preview if token is passed
124124
"""
125125
page = None
126-
# try:
127-
# Generate queryset based on given key & Optimise query based on request AST
128-
pages = WagtailPage.objects.live().public()
129-
pages = QueryOptimzer.query(pages, info)
130-
if id:
131-
page = pages.get(id=id)
132-
elif slug:
133-
page = pages.get(slug=slug)
134-
elif url:
135-
for matching_page in pages.filter(url_path__contains=url):
136-
if matching_page.url == url:
137-
page = matching_page
138-
break
139-
140-
if page:
141-
page = page.specific
142-
143-
if token:
126+
try:
127+
# Generate queryset based on given key & Optimise query based on request AST
128+
pages = WagtailPage.objects.live().public()
129+
pages = QueryOptimzer.query(pages, info)
130+
if id:
131+
page = pages.get(id=id)
132+
elif slug:
133+
page = pages.get(slug=slug)
134+
144135
if page:
145-
page_type = type(page)
146-
if hasattr(page_type, "get_page_from_preview_token"):
147-
page = page_type.get_page_from_preview_token(token)
136+
page = page.specific
137+
138+
if token:
139+
if page:
140+
page_type = type(page)
141+
if hasattr(page_type, "get_page_from_preview_token"):
142+
page = page_type.get_page_from_preview_token(token)
148143

149-
elif content_type:
150-
app_label, model = content_type.lower().split(".")
151-
mdl = ContentType.objects.get(app_label=app_label, model=model)
152-
cls = mdl.model_class()
153-
if hasattr(cls, "get_page_from_preview_token"):
154-
page = cls.get_page_from_preview_token(token)
144+
elif content_type:
145+
app_label, model = content_type.lower().split(".")
146+
mdl = ContentType.objects.get(app_label=app_label, model=model)
147+
cls = mdl.model_class()
148+
if hasattr(cls, "get_page_from_preview_token"):
149+
page = cls.get_page_from_preview_token(token)
155150

156-
# except BaseException:
157-
# page = None
151+
except BaseException:
152+
page = None
158153

159154
return page
160155

@@ -169,7 +164,6 @@ class Mixin:
169164
PageInterface,
170165
id=graphene.Int(),
171166
slug=graphene.String(),
172-
url=graphene.String(),
173167
token=graphene.String(),
174168
content_type=graphene.String(),
175169
)
@@ -185,7 +179,6 @@ def resolve_page(self, info, **kwargs):
185179
return get_specific_page(
186180
id=kwargs.get("id"),
187181
slug=kwargs.get("slug"),
188-
url=kwargs.get("url"),
189182
token=kwargs.get("token"),
190183
content_type=kwargs.get("content_type"),
191184
info=info,

grapple/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import base64
33
import tempfile
4-
import graphene_django_optimizer as gql_optimizer
54
from PIL import Image, ImageFilter
65
from django.conf import settings
76
from wagtail.search.index import class_is_indexed

0 commit comments

Comments
 (0)