Skip to content
Open
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
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
5.0.20 (unreleased)
-------------------

- Nothing changed yet.
- Fix translation for unique values in form patch.
[cekk]


5.0.19 (2025-11-17)
Expand Down
58 changes: 58 additions & 0 deletions src/design/plone/policy/locales/design.plone.policy.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#--- PLEASE EDIT THE LINES BELOW CORRECTLY ---
#SOME DESCRIPTIVE TITLE.
#FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-12-12 09:46+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0\n"
"Language-Code: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: design.plone.policy\n"

#: ../configure.zcml:24
msgid "Design Plone: policy"
msgstr ""

#: ../configure.zcml:39
msgid "Design Plone: policy (to_1400)"
msgstr ""

#: ../configure.zcml:32
msgid "Design Plone: policy (uninstall)"
msgstr ""

#: ../configure.zcml:24
msgid "Installs the design.plone.policy add-on."
msgstr ""

#: ../configure.zcml:32
msgid "Uninstalls the design.plone.policy add-on."
msgstr ""

#. Default: "Unable to send confirm email. Please retry later or contact site administrator."
#: ../patches/collective_volto_formsupport.py:116
msgid "mail_send_exception"
msgstr ""

#. Default: "No"
#: ../patches/collective_volto_formsupport.py:59
msgid "no_label"
msgstr ""

#. Default: "Unable to save data. The value of field \"${field}\" is already stored in previous submissions."
#: ../patches/collective_volto_formsupport.py:205
msgid "save_data_exception"
msgstr ""

#. Default: "Yes"
#: ../patches/collective_volto_formsupport.py:57
msgid "yes_label"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-12-12 09:46+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0\n"
"Language-Code: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: DOMAIN\n"

#: ../configure.zcml:24
msgid "Design Plone: policy"
msgstr ""

#: ../configure.zcml:39
msgid "Design Plone: policy (to_1400)"
msgstr ""

#: ../configure.zcml:32
msgid "Design Plone: policy (uninstall)"
msgstr ""

#: ../configure.zcml:24
msgid "Installs the design.plone.policy add-on."
msgstr ""

#: ../configure.zcml:32
msgid "Uninstalls the design.plone.policy add-on."
msgstr ""

#. Default: "Unable to send confirm email. Please retry later or contact site administrator."
#: ../patches/collective_volto_formsupport.py:116
msgid "mail_send_exception"
msgstr ""

#. Default: "No"
#: ../patches/collective_volto_formsupport.py:59
msgid "no_label"
msgstr ""

#. Default: "Unable to save data. The value of field \"${field}\" is already stored in previous submissions."
#: ../patches/collective_volto_formsupport.py:205
#, fuzzy
msgid "save_data_exception"
msgstr "Impossibile sottomettere il form. Valore non univoco: \"${fields}\""

#. Default: "Yes"
#: ../patches/collective_volto_formsupport.py:57
msgid "yes_label"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-12-12 08:28+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0\n"
"Language-Code: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: DOMAIN\n"

#. Default: "Unable to save data. The value of field \"${field}\" is already stored in previous submissions."
#: ../patches/collective_volto_formsupport.py:205
msgid "save_data_exception"
msgstr "Non è possibile inviare il modulo, poiché il valore nel campo \"${field}\" è già presente."
37 changes: 14 additions & 23 deletions src/design/plone/policy/patches/collective_volto_formsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from datetime import datetime
from io import StringIO
from plone.protect.interfaces import IDisableCSRFProtection
from plone import api
from souper.soup import Record
from zExceptions import BadRequest
from zope.component import getMultiAdapter
Expand Down Expand Up @@ -124,20 +125,7 @@ def reply(self):
notify(FormSubmittedEvent(self.context, self.block, self.form_data))

if store_action:
try:
self.store_data()
except ValueError as e:
logger.exception(e)
message = translate(
_(
"save_data_exception",
default="Unable to save data. Value not unique: '${fields}'",
mapping={"fields": e.args[0]},
),
context=self.request,
)
self.request.response.setStatus(500)
return dict(type="InternalServerError", message=message)
self.store_data()

# start patch - append waiting_list to response
res = {"data": self.form_data.get("data", [])}
Expand Down Expand Up @@ -208,16 +196,19 @@ def add(self, data):
if keys:
saved_data = self.soup.data.values()
for saved_record in saved_data:
unique = False
for key in keys:
if record.attrs.storage[key[0]] != saved_record.attrs.storage.get(
key[0], None
):
unique = True
break

if not unique:
raise ValueError(f" {', '.join([x[1] for x in keys])}")
saved_value = saved_record.attrs.storage.get(key[0], None)
submit_value = record.attrs.storage.get(key[0], None)
if submit_value and submit_value == saved_value:
raise BadRequest(
api.portal.translate(
_(
"save_data_exception",
default='Unable to save data. The value of field "${field}" is already stored in previous submissions.',
mapping={"field": key[1]},
)
)
)
# end patch

return self.soup.add(record)
Expand Down
Loading