Skip to content

Commit

Permalink
Merge pull request #2 from RedTurtle/add_plone2volto_url_convert
Browse files Browse the repository at this point in the history
Add plone2volto url convert
  • Loading branch information
luca-bellenghi authored Apr 29, 2024
2 parents dc5b756 + 75cb46b commit 8ab0399
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
1.1.3 (unreleased)
------------------

- Nothing changed yet.
- add a plone2volto url conversion method on feedback download
[lucabel]


1.1.2 (2024-03-15)
Expand Down
11 changes: 10 additions & 1 deletion src/collective/feedback/restapi/services/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ def render(self):
)
self.request.response.write(data)

def plone2volto(self, url):
portal_url = api.portal.get().absolute_url()
frontend_domain = api.portal.get_registry_record(
"volto.frontend_domain", default=""
)
if frontend_domain and url.startswith(portal_url):
return url.replace(portal_url, frontend_domain, 1)
return url

def get_data(self):
tool = getUtility(ICollectiveFeedbackStore)
sbuf = StringIO()
Expand All @@ -240,7 +249,7 @@ def get_data(self):
val = json_compatible(v)
data[k] = val

data["url"] = obj.absolute_url()
data["url"] = self.plone2volto(obj.absolute_url())
rows.append(data)

writer = csv.DictWriter(sbuf, fieldnames=columns, delimiter=",")
Expand Down

0 comments on commit 8ab0399

Please sign in to comment.