Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix volto.formsupport path to not alter returned data on POST. #74

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/design/plone/policy/patches/collective_volto_formsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,25 @@ def reply(self):
self.request.response.setStatus(500)
return dict(type="InternalServerError", message=message)

return {"data": data}
res = {"data": data}
waiting_list = (
self.submit_limit is not None and -1 < self.submit_limit < self.count_data()
)
if waiting_list:
res["waiting_list"] = waiting_list
# end patch
return res


def store_data(self):
store = getMultiAdapter((self.context, self.request), IFormDataStore)
# start patch
data = {"form_data": self.filter_parameters()}
data = self.filter_parameters()

res = store.add(data=data)
if not res:
raise BadRequest("Unable to store data")

waiting_list = (
self.submit_limit is not None and -1 < self.submit_limit < self.count_data()
)
data.update({"waiting_list": waiting_list})

return data


Expand Down Expand Up @@ -205,7 +206,7 @@ def add(self, data):
fields_labels = {}
fields_order = []
# start patch
for field_data in data["form_data"]:
for field_data in data:
# end patch
field_id = field_data.get("field_id", "")
value = field_data.get("value", "")
Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/policy/tests/test_limit_submit_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_limit_submit(self):
)
transaction.commit()
self.assertEqual(response.status_code, 200)
self.assertTrue(response.json()["data"]["waiting_list"])
self.assertTrue(response.json()["waiting_list"])

def test_unique_field(self):
self.document.blocks = {
Expand Down
4 changes: 4 additions & 0 deletions test_plone60.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ importlib-metadata = 5.2.0
# Added by buildout at 2023-03-01 12:57:48.164146
coverage = 7.0.5
createcoverage = 1.5

# temporary version
collective.taxonomy = 3.1.5
collective.volto.blocksfield = 2.2.0
Loading