Commit c5a9d1df authored by Jérome Perrin's avatar Jérome Perrin

fix WebPage.getImplicitSuccessorValueList in the context of web site

Fix a problem with `WebPage.getImplicitSuccessorValueList`, it did not detect references such as:

```
<img src="reference">
```

when the web page was in the context of a web site, because of some wrong relative URL calculations.

See merge request nexedi/erp5!1153
parents 1e2c40e2 a64ceb40
Pipeline #9923 passed with stage
......@@ -1608,7 +1608,7 @@ return True
web_page_module = self.portal.getDefaultModule(portal_type="Web Page")
image_module = self.portal.getDefaultModule(portal_type="Image")
img_list = []
for i in range(13):
for i in range(14):
img = image_module.newContent(
data=XSMALL_SVG_IMAGE_ICON_DATA,
reference="P-IMG-implicit.successor.value.list.test.%d" % i,
......@@ -1638,17 +1638,29 @@ return True
'<img src="P-IMG-implicit.successor.value.list.test.10?format=" />',
'<iframe src="/%s" />' % img_list[11].getRelativeUrl(),
'<style>body { background-image: url("P-IMG-implicit.successor.value.list.test.12?format=png"); }</style>',
'<script src="P-IMG-implicit.successor.value.list.test.13" type="text/javascript"></script>',
]),
)
page.publish()
self.tic()
# Test part
self.maxDiff = None
successor_list = self.portal.web_site_module.test\
.restrictedTraverse("P-WP-implicit.successor.value.list.test")\
.getImplicitSuccessorValueList()
self.assertEqual(
sorted([s.getUid() for s in successor_list]),
sorted([i.getUid() for i in img_list]),
sorted([s.getReference() for s in successor_list]),
sorted([i.getReference() for i in img_list]),
)
# same with the web page retrieved with getDocumentValue
successor_list = self.portal.web_site_module.test.getDocumentValue(
"P-WP-implicit.successor.value.list.test"
).getImplicitSuccessorValueList()
self.assertEqual(
sorted([s.getReference() for s in successor_list]),
sorted([i.getReference() for i in img_list]),
)
def checkWebSiteDocumentViewConsistency(self, portal_type, module_id="document_module"):
......
......@@ -122,7 +122,7 @@ else:
root_url = base_url_root_object.absolute_url()
base_url = base_url_object.absolute_url()
base_path = "."
base_path = "/"
if base_url_object.getRelativeUrl().startswith(base_url_root_object.getRelativeUrl()):
base_path = base_url_object.getRelativeUrl()[len(base_url_root_object.getRelativeUrl()):]
if base_path and not base_path.startswith("/"):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment