Skip to content

Commit

Permalink
Merge branch 'main' into erral-issue-1835
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens authored Nov 7, 2024
2 parents aaa956b + 9f0feff commit 8de96e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Changelog
.. towncrier release notes start
9.8.4 (2024-11-05)
------------------

Bug fixes:


- URL Management control panel: Fix error handling in CSV upload. @davisagli (#1837)


9.8.3 (2024-11-01)
------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys


version = "9.8.4.dev0"
version = "9.8.5.dev0"

if sys.version_info.major == 2:
raise ValueError(
Expand Down
10 changes: 10 additions & 0 deletions src/plone/restapi/services/aliases/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,22 @@ def _reply_csv(self):
raise BadRequest("Uploaded file is not a valid CSV file")

controlpanel = RedirectsControlPanel(self.context, self.request)
csv_errors = controlpanel.csv_errors = []
storage = getUtility(IRedirectionStorage)
status = IStatusMessage(self.request)
portal = getSite()
controlpanel.upload(file, portal, storage, status)
file.close()

if csv_errors:
self.request.response.setHeader("Content-Type", "application/json")
self.request.response.setStatus(BadRequest)
return {
"type": "BadRequest",
"message": f"Found {len(csv_errors)} errors in CSV file.",
# Skip first item which is a notice about the delimiter
"csv_errors": csv_errors[1:],
}
if err := status.show():
if err[0].type == "error":
raise BadRequest(err[0].message)
Expand Down

0 comments on commit 8de96e9

Please sign in to comment.