Skip to content
This repository
Browse code

Make page_resolver.is_valid_url multisite aware, fixes #1426

  • Loading branch information...
commit dd493fd78c7ffe19d04ec88bb290d11f024c13ff 1 parent 3e52d6b
Iacopo Spalletti authored September 14, 2012

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. 8  cms/utils/page_resolver.py
8  cms/utils/page_resolver.py
@@ -137,16 +137,20 @@ def get_page_from_request(request, use_path=None):
137 137
     return page
138 138
 
139 139
 
140  
-def is_valid_url(url,instance,create_links=True):
  140
+def is_valid_url(url,instance,create_links=True, site=None):
141 141
     """ Checks for conflicting urls
142 142
     """
143 143
     if url:
144 144
         # Url sanity check via regexp
145 145
         if not any_path_re.match(url):
146 146
             raise ValidationError(_('Invalid URL, use /my/url format.'))
  147
+        # We only check page FK to site object to allow is_valid_url check on
  148
+        # incomplete Page instances
  149
+        if not site and (instance.site_id):
  150
+            site = instance.site
147 151
         # Retrieve complete queryset of pages with corresponding URL
148 152
         # This uses the same resolving function as ``get_page_from_path``
149  
-        page_qs = get_page_queryset_from_path(url.strip('/'))
  153
+        page_qs = get_page_queryset_from_path(url.strip('/'), site=site)
150 154
         url_clashes = []
151 155
         # If queryset has pages checks for conflicting urls
152 156
         if page_qs is not None:

0 notes on commit dd493fd

Please sign in to comment.
Something went wrong with that request. Please try again.