Skip to content

Commit e6c1dee

Browse files
committed
Fixed an error in is_valid_url() when CMS_MODERATOR is active
1 parent 8c56f86 commit e6c1dee

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cms/utils/page_resolver.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ def get_page_queryset_from_path(path, preview=False):
4040
except Page.DoesNotExist:
4141
page = None
4242
return page
43-
43+
4444
if not settings.CMS_MODERATOR or preview:
4545
# We do not use moderator
4646
pages = Page.objects.drafts()
4747
else:
4848
pages = Page.objects.public()
49-
49+
5050
if not preview:
5151
pages = pages.published()
5252

@@ -151,7 +151,9 @@ def is_valid_url(url,instance,create_links=True):
151151
page_qs = [page_qs]
152152
for page in page_qs:
153153
# Every page in the queryset except the current one is a conflicting page
154-
if page and page.pk != instance.pk:
154+
# When CMS_MODERATOR is active we have to exclude both copies of the page
155+
if page and ((not settings.CMS_MODERATOR and page.pk != instance.pk) or
156+
(settings.CMS_MODERATOR and page.publisher_public.pk != instance.pk)):
155157
if create_links:
156158
# Format return message with page url
157159
url_clashes.append('<a href="%(page_url)s%(pk)s" target="_blank">%(page_title)s</a>' %
@@ -167,4 +169,4 @@ def is_valid_url(url,instance,create_links=True):
167169
'Pages %(pages)s have the same url \'%(url)s\' as current page "%(instance)s".',
168170
len(url_clashes)) %
169171
{'pages':", ".join(url_clashes),'url':url,'instance':instance}))
170-
return True
172+
return True

0 commit comments

Comments
 (0)