-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/main Date: 2024-11-05T12:55:02-08:00 Author: David Glick (davisagli) <[email protected]> Commit: plone/plone.restapi@636ef37 Fix handling of errors in aliases CSV upload (#1838) * Fix handling of errors in aliases CSV upload * changelog Files changed: A news/1837.bugfix M src/plone/restapi/services/aliases/add.py
- Loading branch information
Showing
1 changed file
with
13 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
Repository: plone.app.multilingual | ||
Repository: plone.restapi | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-11-04T23:00:11+01:00 | ||
Author: Yuri (yurj) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.multilingual/commit/52e6a1946dfacb0d2e03fe0b78c45a34a09ed6f6 | ||
Branch: refs/heads/main | ||
Date: 2024-11-05T12:55:02-08:00 | ||
Author: David Glick (davisagli) <[email protected]> | ||
Commit: https://github.com/plone/plone.restapi/commit/636ef37ecf1fce3de17c80fa29e6cac7e6ffbcac | ||
|
||
Rename 472.bug to 472.bugfix | ||
Fix handling of errors in aliases CSV upload (#1838) | ||
|
||
* Fix handling of errors in aliases CSV upload | ||
|
||
* changelog | ||
|
||
Files changed: | ||
A news/472.bugfix | ||
D news/472.bug | ||
A news/1837.bugfix | ||
M src/plone/restapi/services/aliases/add.py | ||
|
||
b'diff --git a/news/472.bug b/news/472.bugfix\nsimilarity index 100%\nrename from news/472.bug\nrename to news/472.bugfix\n' | ||
b'diff --git a/news/1837.bugfix b/news/1837.bugfix\nnew file mode 100644\nindex 0000000000..08502b6c36\n--- /dev/null\n+++ b/news/1837.bugfix\n@@ -0,0 +1 @@\n+URL Management control panel: Fix error handling in CSV upload. @davisagli\ndiff --git a/src/plone/restapi/services/aliases/add.py b/src/plone/restapi/services/aliases/add.py\nindex e54ccc0c67..2894d25b22 100644\n--- a/src/plone/restapi/services/aliases/add.py\n+++ b/src/plone/restapi/services/aliases/add.py\n@@ -101,12 +101,22 @@ def _reply_csv(self):\n raise BadRequest("Uploaded file is not a valid CSV file")\n \n controlpanel = RedirectsControlPanel(self.context, self.request)\n+ csv_errors = controlpanel.csv_errors = []\n storage = getUtility(IRedirectionStorage)\n status = IStatusMessage(self.request)\n portal = getSite()\n controlpanel.upload(file, portal, storage, status)\n file.close()\n \n+ if csv_errors:\n+ self.request.response.setHeader("Content-Type", "application/json")\n+ self.request.response.setStatus(BadRequest)\n+ return {\n+ "type": "BadRequest",\n+ "message": f"Found {len(csv_errors)} errors in CSV file.",\n+ # Skip first item which is a notice about the delimiter\n+ "csv_errors": csv_errors[1:],\n+ }\n if err := status.show():\n if err[0].type == "error":\n raise BadRequest(err[0].message)\n' | ||
|