From 10e3e8ea53dc664f22293ddbd84f4413e788296a Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Mon, 24 Jun 2024 14:26:49 +0200 Subject: [PATCH 01/14] Add unique fields manage --- .../volto/formsupport/datamanager/catalog.py | 22 +++++++++ .../restapi/services/submit_form/post.py | 45 ++++++++++++++++--- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index f746119c..ae4e6e62 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -96,12 +96,27 @@ def add(self, data): record.attrs["fields_order"] = fields_order record.attrs["date"] = datetime.now() record.attrs["block_id"] = self.block_id + + keys = [x["field_id"] for x in form_fields if x.get("unique", False)] + 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] != saved_record.attrs.storage[key]: + unique = True + break + + if not unique: + raise ValueError("Value not unique") + return self.soup.add(record) def length(self): return len([x for x in self.soup.data.values()]) def search(self, query=None): + records = [] if not query: records = sorted( self.soup.data.values(), @@ -110,6 +125,13 @@ def search(self, query=None): ) return records + def count(self, query=None): + records = [] + if not query: + records = self.soup.data.values() + + return len(records) + def delete(self, id): record = self.soup.get(id) del self.soup[record] diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py index a80d702f..73c04167 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -48,6 +48,10 @@ class SubmitPost(Service): def __init__(self, context, request): super().__init__(context, request) + self.send_action = False + self.store_action = False + self.submit_limit = -1 + self.block = {} self.form_data = self.cleanup_data() self.block_id = self.form_data.get("block_id", "") @@ -57,15 +61,17 @@ def __init__(self, context, request): def reply(self): self.validate_form() - store_action = self.block.get("store", False) - send_action = self.block.get("send", []) + self.store_action = self.block.get("store", False) + self.send_action = self.block.get("send", []) + self.submit_limit = self.block.get("limit", -1) # Disable CSRF protection alsoProvides(self.request, IDisableCSRFProtection) notify(PostEventService(self.context, self.form_data)) + data = self.form_data.get("data", []) - if send_action: + if self.send_action: try: self.send_data() except BadRequest as e: @@ -81,10 +87,22 @@ def reply(self): ) self.request.response.setStatus(500) return dict(type="InternalServerError", message=message) - if store_action: - self.store_data() + if self.store_action: + try: + data = self.store_data() + except ValueError as e: + logger.exception(e) + message = translate( + _( + "save_data_exception", + default="Unable to save data. Value not unique.", + ), + context=self.request, + ) + self.request.response.setStatus(500) + return dict(type="InternalServerError", message=message) - return {"data": self.form_data.get("data", [])} + return {"data": data} def cleanup_data(self): """ @@ -500,6 +518,19 @@ def attach_xml(self, msg): def store_data(self): store = getMultiAdapter((self.context, self.request), IFormDataStore) - res = store.add(data=self.filter_parameters()) + data = self.filter_parameters() + + if self.submit_limit is not None and -1 < self.submit_limit < self.count_data(): + data.append({"value": True, "label": "Lista d'attesa"}) + else: + data.append({"value": False, "label": "Lista d'attesa"}) + + res = store.add(data=data) if not res: raise BadRequest("Unable to store data") + + return data + + def count_data(self): + store = getMultiAdapter((self.context, self.request), IFormDataStore) + return store.count() From cdbdd6c6a246d6f17119f7a13fc255aeda7ee819 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Mon, 24 Jun 2024 15:24:55 +0200 Subject: [PATCH 02/14] waiting_list --- src/collective/volto/formsupport/datamanager/catalog.py | 3 ++- .../volto/formsupport/restapi/services/form_data/csv.py | 2 +- .../volto/formsupport/restapi/services/submit_form/post.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index ae4e6e62..84db4f6d 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -85,13 +85,14 @@ def add(self, data): record = Record() fields_labels = {} fields_order = [] - for field_data in data: + for field_data in data["form_data"]: field_id = field_data.get("field_id", "") value = field_data.get("value", "") if field_id in fields: record.attrs[field_id] = value fields_labels[field_id] = fields[field_id] fields_order.append(field_id) + record.attrs["waiting_list"] = data["waiting_list"] record.attrs["fields_labels"] = fields_labels record.attrs["fields_order"] = fields_order record.attrs["date"] = datetime.now() diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index bf752905..44c16a94 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -64,7 +64,7 @@ def render(self): def get_data(self): store = getMultiAdapter((self.context, self.request), IFormDataStore) sbuf = StringIO() - fixed_columns = ["date"] + fixed_columns = ["date", "waiting_list"] columns = [] rows = [] diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py index 73c04167..2a5e778c 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -518,12 +518,12 @@ def attach_xml(self, msg): def store_data(self): store = getMultiAdapter((self.context, self.request), IFormDataStore) - data = self.filter_parameters() + data = {"form_data": self.filter_parameters()} if self.submit_limit is not None and -1 < self.submit_limit < self.count_data(): - data.append({"value": True, "label": "Lista d'attesa"}) + data.update({"waiting_list": True}) else: - data.append({"value": False, "label": "Lista d'attesa"}) + data.update({"waiting_list": False}) res = store.add(data=data) if not res: From 5142d34faa451827e8b2384dd1346c7bfcd4561b Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Mon, 24 Jun 2024 15:53:59 +0200 Subject: [PATCH 03/14] fix: fixed export --- .../volto/formsupport/restapi/services/form_data/csv.py | 4 +++- .../volto/formsupport/restapi/services/submit_form/post.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index 44c16a94..7f27bedb 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -64,7 +64,9 @@ def render(self): def get_data(self): store = getMultiAdapter((self.context, self.request), IFormDataStore) sbuf = StringIO() - fixed_columns = ["date", "waiting_list"] + fixed_columns = ["date"] + if getattr(self.form_block, "limit", None) is not None: + fixed_columns.append("limit") columns = [] rows = [] diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py index 2a5e778c..d177f4e5 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -50,7 +50,7 @@ def __init__(self, context, request): self.send_action = False self.store_action = False - self.submit_limit = -1 + self.submit_limit = None self.block = {} self.form_data = self.cleanup_data() @@ -522,7 +522,7 @@ def store_data(self): if self.submit_limit is not None and -1 < self.submit_limit < self.count_data(): data.update({"waiting_list": True}) - else: + elif self.submit_limit is not None: data.update({"waiting_list": False}) res = store.add(data=data) From 46edfd300578913239b0eb808ab046db909dcdd9 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Mon, 24 Jun 2024 16:55:23 +0200 Subject: [PATCH 04/14] fix: errors for value not uique --- src/collective/volto/formsupport/datamanager/catalog.py | 2 +- .../volto/formsupport/restapi/services/submit_form/post.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index 84db4f6d..d04a503a 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -109,7 +109,7 @@ def add(self, data): break if not unique: - raise ValueError("Value not unique") + raise ValueError(f"Value not unique: {', '.join(keys)}") return self.soup.add(record) diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py index d177f4e5..ef7144bc 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -95,7 +95,7 @@ def reply(self): message = translate( _( "save_data_exception", - default="Unable to save data. Value not unique.", + default=f"Unable to save data. {e.args[0]}", ), context=self.request, ) From 6f6f69e9232f182f3bb990ceaa943ea3ebbcc275 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Mon, 24 Jun 2024 17:00:50 +0200 Subject: [PATCH 05/14] fix: errors for value not unique --- .../volto/formsupport/datamanager/catalog.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index d04a503a..f4230a47 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -98,18 +98,20 @@ def add(self, data): record.attrs["date"] = datetime.now() record.attrs["block_id"] = self.block_id - keys = [x["field_id"] for x in form_fields if x.get("unique", False)] - if keys: + keys = [ + (x["field_id"], x["label"]) for x in form_fields if x.get("unique", False) + ] + if keys[0]: saved_data = self.soup.data.values() for saved_record in saved_data: unique = False - for key in keys: + for key in keys[0]: if record.attrs.storage[key] != saved_record.attrs.storage[key]: unique = True break if not unique: - raise ValueError(f"Value not unique: {', '.join(keys)}") + raise ValueError(f"Value not unique: {', '.join(keys[1])}") return self.soup.add(record) From 6f718dedc5c81a21c3227607a3fd4c7f054dde67 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Mon, 24 Jun 2024 17:19:42 +0200 Subject: [PATCH 06/14] fix: errors for value not unique --- .../volto/formsupport/datamanager/catalog.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index f4230a47..5d52990f 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -101,17 +101,22 @@ def add(self, data): keys = [ (x["field_id"], x["label"]) for x in form_fields if x.get("unique", False) ] - if keys[0]: + if keys: saved_data = self.soup.data.values() for saved_record in saved_data: unique = False - for key in keys[0]: - if record.attrs.storage[key] != saved_record.attrs.storage[key]: + for key in keys: + if ( + record.attrs.storage[key[0]] + != saved_record.attrs.storage[key[0]] + ): unique = True break if not unique: - raise ValueError(f"Value not unique: {', '.join(keys[1])}") + raise ValueError( + f"Value not unique: {', '.join([x[1] for x in keys])}" + ) return self.soup.add(record) From ce50e8a42bab68c9f24be0101cb1afc86ef3bcc4 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Tue, 25 Jun 2024 10:43:24 +0200 Subject: [PATCH 07/14] fix: limit --- src/collective/volto/formsupport/datamanager/catalog.py | 4 +--- .../volto/formsupport/restapi/services/form_data/csv.py | 4 ++-- .../volto/formsupport/restapi/services/submit_form/post.py | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index 5d52990f..278c0b7f 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -114,9 +114,7 @@ def add(self, data): break if not unique: - raise ValueError( - f"Value not unique: {', '.join([x[1] for x in keys])}" - ) + raise ValueError(f" {', '.join([x[1] for x in keys])}") return self.soup.add(record) diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index 7f27bedb..86d9b403 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -65,8 +65,8 @@ def get_data(self): store = getMultiAdapter((self.context, self.request), IFormDataStore) sbuf = StringIO() fixed_columns = ["date"] - if getattr(self.form_block, "limit", None) is not None: - fixed_columns.append("limit") + if self.form_block.get("limit", None) is not None: + fixed_columns.append("waiting_list") columns = [] rows = [] diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py index ef7144bc..39dd0411 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -63,7 +63,7 @@ def reply(self): self.store_action = self.block.get("store", False) self.send_action = self.block.get("send", []) - self.submit_limit = self.block.get("limit", -1) + self.submit_limit = int(self.block.get("limit", "-1")) # Disable CSRF protection alsoProvides(self.request, IDisableCSRFProtection) @@ -95,7 +95,7 @@ def reply(self): message = translate( _( "save_data_exception", - default=f"Unable to save data. {e.args[0]}", + default=f"Unable to save data. Value not unique: {e.args[0]}", ), context=self.request, ) From 7ef43e3323be21b5887ec8c0044a4a94dbdd50ba Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Tue, 25 Jun 2024 11:25:48 +0200 Subject: [PATCH 08/14] fix: removed waiting_list info from catalog --- .../volto/formsupport/datamanager/catalog.py | 1 - .../formsupport/restapi/services/form_data/csv.py | 12 +++++++++--- .../formsupport/restapi/services/submit_form/post.py | 12 +++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index 278c0b7f..2d825451 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -92,7 +92,6 @@ def add(self, data): record.attrs[field_id] = value fields_labels[field_id] = fields[field_id] fields_order.append(field_id) - record.attrs["waiting_list"] = data["waiting_list"] record.attrs["fields_labels"] = fields_labels record.attrs["fields_order"] = fields_order record.attrs["date"] = datetime.now() diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index 86d9b403..3654dffb 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -65,12 +65,13 @@ def get_data(self): store = getMultiAdapter((self.context, self.request), IFormDataStore) sbuf = StringIO() fixed_columns = ["date"] - if self.form_block.get("limit", None) is not None: - fixed_columns.append("waiting_list") columns = [] + custom_colums = [] + if self.form_block.get("limit", None) is not None: + custom_colums.append("Lista d'attesa") rows = [] - for item in store.search(): + for index, item in enumerate(store.search()): data = {} fields_labels = item.attrs.get("fields_labels", {}) for k in self.get_ordered_keys(item): @@ -85,8 +86,13 @@ def get_data(self): # add fixed columns values value = item.attrs.get(k, None) data[k] = json_compatible(value) + if "Lista d'attesa" in custom_colums: + limit = int(self.form_block["limit"]) + data.update({"Lista d'attesa": not (index < limit)}) + rows.append(data) columns.extend(fixed_columns) + columns.extend(custom_colums) writer = csv.DictWriter(sbuf, fieldnames=columns, quoting=csv.QUOTE_ALL) writer.writeheader() for row in rows: diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py index 39dd0411..8299aa17 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -520,15 +520,17 @@ def store_data(self): store = getMultiAdapter((self.context, self.request), IFormDataStore) data = {"form_data": self.filter_parameters()} - if self.submit_limit is not None and -1 < self.submit_limit < self.count_data(): - data.update({"waiting_list": True}) - elif self.submit_limit is not None: - data.update({"waiting_list": False}) - res = store.add(data=data) if not res: raise BadRequest("Unable to store data") + data.update( + { + "waiting_list": self.submit_limit is not None + and -1 < self.submit_limit < self.count_data() + } + ) + return data def count_data(self): From 98d904e5a4cc12c8ee822d888a231c264a60a812 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Tue, 25 Jun 2024 12:02:42 +0200 Subject: [PATCH 09/14] fix: removed waiting_list info from catalog --- .../volto/formsupport/restapi/services/form_data/csv.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index 3654dffb..68d5b26a 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -68,7 +68,9 @@ def get_data(self): columns = [] custom_colums = [] if self.form_block.get("limit", None) is not None: - custom_colums.append("Lista d'attesa") + limit = int(self.form_block["limit"]) + if limit > -1: + custom_colums.append("Lista d'attesa") rows = [] for index, item in enumerate(store.search()): @@ -87,7 +89,6 @@ def get_data(self): value = item.attrs.get(k, None) data[k] = json_compatible(value) if "Lista d'attesa" in custom_colums: - limit = int(self.form_block["limit"]) data.update({"Lista d'attesa": not (index < limit)}) rows.append(data) From 412ae3cabd17ed95caa015e2795ce59792d78e3e Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Tue, 25 Jun 2024 12:18:37 +0200 Subject: [PATCH 10/14] traslation --- .../locales/collective.volto.formsupport.pot | 41 ++++++++++++----- .../collective.volto.formsupport.po | 45 +++++++++++++------ .../collective.volto.formsupport.po | 45 +++++++++++++------ .../collective.volto.formsupport.po | 45 +++++++++++++------ .../collective.volto.formsupport.po | 44 ++++++++++++------ .../restapi/services/submit_form/post.py | 3 +- 6 files changed, 158 insertions(+), 65 deletions(-) diff --git a/src/collective/volto/formsupport/locales/collective.volto.formsupport.pot b/src/collective/volto/formsupport/locales/collective.volto.formsupport.pot index e64e4fcf..9234da8e 100644 --- a/src/collective/volto/formsupport/locales/collective.volto.formsupport.pot +++ b/src/collective/volto/formsupport/locales/collective.volto.formsupport.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-06-07 00:42+0000\n" +"POT-Creation-Date: 2024-06-25 10:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -21,6 +21,10 @@ msgstr "" msgid "Email confirmation code" msgstr "" +#: ../browser/send_mail_template_table.pt:18 +msgid "Field" +msgstr "" + #: ../captcha/recaptcha.py:12 msgid "Google ReCaptcha" msgstr "" @@ -55,6 +59,10 @@ msgstr "" msgid "OTP is wrong" msgstr "" +#: ../browser/templates/email_confirm_view.pt:17 +msgid "Simple Transactional Email" +msgstr "" + #: ../captcha/hcaptcha.py:56 #: ../captcha/norobots.py:65 #: ../captcha/recaptcha.py:54 @@ -85,6 +93,10 @@ msgstr "" msgid "Uninstalls the collective.volto.formsupport add-on." msgstr "" +#: ../browser/send_mail_template_table.pt:23 +msgid "Value" +msgstr "" + #: ../configure.zcml:34 msgid "Volto: Form support" msgstr "" @@ -98,17 +110,17 @@ msgid "Your code to validate the email address:" msgstr "" #. Default: "Attachments too big. You uploaded ${uploaded_str}, but limit is ${max} MB. Try to compress files." -#: ../restapi/services/submit_form/post.py:215 +#: ../restapi/services/submit_form/post.py:234 msgid "attachments_too_big" msgstr "" #. Default: "Block with @type \"form\" and id \"$block\" not found in this context: $context" -#: ../restapi/services/submit_form/post.py:130 +#: ../restapi/services/submit_form/post.py:149 msgid "block_form_not_found_label" msgstr "" #. Default: "Empty form data." -#: ../restapi/services/submit_form/post.py:156 +#: ../restapi/services/submit_form/post.py:175 msgid "empty_form_data" msgstr "" @@ -118,22 +130,27 @@ msgid "honeypot_error" msgstr "" #. Default: "Unable to send confirm email. Please retry later or contact site administrator." -#: ../restapi/services/submit_form/post.py:76 +#: ../restapi/services/submit_form/post.py:82 msgid "mail_send_exception" msgstr "" #. Default: "You need to set at least one form action between \"send\" and \"store\"." -#: ../restapi/services/submit_form/post.py:145 +#: ../restapi/services/submit_form/post.py:164 msgid "missing_action" msgstr "" #. Default: "Missing block_id" -#: ../restapi/services/submit_form/post.py:123 +#: ../restapi/services/submit_form/post.py:142 msgid "missing_blockid_label" msgstr "" -#. Default: "A new form has been submitted from ${url}" -#: ../browser/send_mail_template.pt:22 +#. Default: "Unable to save data. Value not unique: '${fields}'" +#: ../restapi/services/submit_form/post.py:96 +msgid "save_data_exception" +msgstr "" + +#. Default: "A new form has been submitted from ${url}" +#: ../browser/send_mail_template.pt:24 msgid "send_mail_text" msgstr "" @@ -143,15 +160,15 @@ msgid "send_mail_text_table" msgstr "" #. Default: "Missing required field: subject or from." -#: ../restapi/services/submit_form/post.py:322 +#: ../restapi/services/submit_form/post.py:341 msgid "send_required_field_missing" msgstr "" #. Default: "Email not valid in \"${field}\" field." -#: ../restapi/services/submit_form/post.py:187 +#: ../restapi/services/submit_form/post.py:206 msgid "wrong_email" msgstr "" -#: ../restapi/services/submit_form/post.py:246 +#: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "" diff --git a/src/collective/volto/formsupport/locales/de/LC_MESSAGES/collective.volto.formsupport.po b/src/collective/volto/formsupport/locales/de/LC_MESSAGES/collective.volto.formsupport.po index c1d4c713..d91dd493 100644 --- a/src/collective/volto/formsupport/locales/de/LC_MESSAGES/collective.volto.formsupport.po +++ b/src/collective/volto/formsupport/locales/de/LC_MESSAGES/collective.volto.formsupport.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-06-07 00:42+0000\n" +"POT-Creation-Date: 2024-06-25 10:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,6 +18,10 @@ msgstr "" msgid "Email confirmation code" msgstr "" +#: ../browser/send_mail_template_table.pt:18 +msgid "Field" +msgstr "" + #: ../captcha/recaptcha.py:12 msgid "Google ReCaptcha" msgstr "" @@ -52,6 +56,10 @@ msgstr "" msgid "OTP is wrong" msgstr "" +#: ../browser/templates/email_confirm_view.pt:17 +msgid "Simple Transactional Email" +msgstr "" + #: ../captcha/hcaptcha.py:56 #: ../captcha/norobots.py:65 #: ../captcha/recaptcha.py:54 @@ -82,6 +90,10 @@ msgstr "" msgid "Uninstalls the collective.volto.formsupport add-on." msgstr "" +#: ../browser/send_mail_template_table.pt:23 +msgid "Value" +msgstr "" + #: ../configure.zcml:34 msgid "Volto: Form support" msgstr "" @@ -95,17 +107,17 @@ msgid "Your code to validate the email address:" msgstr "" #. Default: "Attachments too big. You uploaded ${uploaded_str}, but limit is ${max} MB. Try to compress files." -#: ../restapi/services/submit_form/post.py:215 +#: ../restapi/services/submit_form/post.py:234 msgid "attachments_too_big" msgstr "Anhang ist zu groß (${uploaded_str}). Die Größe darf ${max} MB nicht überschreiten. Versuchen Sie Dateien zu komprimieren." #. Default: "Block with @type \"form\" and id \"$block\" not found in this context: $context" -#: ../restapi/services/submit_form/post.py:130 +#: ../restapi/services/submit_form/post.py:149 msgid "block_form_not_found_label" msgstr "Kein Formular-Block mit der ID \"$block\" in diesem Kontext gefunden: $context" #. Default: "Empty form data." -#: ../restapi/services/submit_form/post.py:156 +#: ../restapi/services/submit_form/post.py:175 msgid "empty_form_data" msgstr "Leere Formulardaten." @@ -114,23 +126,30 @@ msgstr "Leere Formulardaten." msgid "honeypot_error" msgstr "Formular konnte nicht abgeschickt werden." -#. Default: "Unable to send confirm email. Please retry later or contact site administator." -#: ../restapi/services/submit_form/post.py:76 +#. Default: "Unable to send confirm email. Please retry later or contact site administrator." +#: ../restapi/services/submit_form/post.py:82 +#, fuzzy msgid "mail_send_exception" msgstr "Die Bestätigungsmail konnte nicht versandt werden. Bitte versuchen Sie es später erneut oder kontaktieren Sie die Seitenadministration." #. Default: "You need to set at least one form action between \"send\" and \"store\"." -#: ../restapi/services/submit_form/post.py:145 +#: ../restapi/services/submit_form/post.py:164 msgid "missing_action" msgstr "Es muss mindestens eine Formular-Aktion gesetzt werden (\"E-Mail an Empfänger senden\" und/oder \"Kompilierte Daten speichern\")." #. Default: "Missing block_id" -#: ../restapi/services/submit_form/post.py:123 +#: ../restapi/services/submit_form/post.py:142 msgid "missing_blockid_label" msgstr "Fehlende block_id" -#. Default: "A new form has been submitted from ${url}" -#: ../browser/send_mail_template.pt:22 +#. Default: "Unable to save data. Value not unique: '${fields}'" +#: ../restapi/services/submit_form/post.py:96 +msgid "save_data_exception" +msgstr "" + +#. Default: "A new form has been submitted from ${url}" +#: ../browser/send_mail_template.pt:24 +#, fuzzy msgid "send_mail_text" msgstr "Auf der Seite ${url} wurde ein neues Formular eingereicht:" @@ -140,15 +159,15 @@ msgid "send_mail_text_table" msgstr "" #. Default: "Missing required field: subject or from." -#: ../restapi/services/submit_form/post.py:322 +#: ../restapi/services/submit_form/post.py:341 msgid "send_required_field_missing" msgstr "Erforderliches Feld fehlt: Betreff oder Absender" #. Default: "Email not valid in \"${field}\" field." -#: ../restapi/services/submit_form/post.py:187 +#: ../restapi/services/submit_form/post.py:206 msgid "wrong_email" msgstr "" -#: ../restapi/services/submit_form/post.py:246 +#: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "" diff --git a/src/collective/volto/formsupport/locales/es/LC_MESSAGES/collective.volto.formsupport.po b/src/collective/volto/formsupport/locales/es/LC_MESSAGES/collective.volto.formsupport.po index 6af88651..b7d32a85 100644 --- a/src/collective/volto/formsupport/locales/es/LC_MESSAGES/collective.volto.formsupport.po +++ b/src/collective/volto/formsupport/locales/es/LC_MESSAGES/collective.volto.formsupport.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: collective.volto.formsupport\n" -"POT-Creation-Date: 2024-06-07 00:42+0000\n" +"POT-Creation-Date: 2024-06-25 10:15+0000\n" "PO-Revision-Date: 2023-05-11 10:11-0400\n" "Last-Translator: Leonardo J. Caballero G. \n" "Language-Team: ES \n" @@ -23,6 +23,10 @@ msgstr "" msgid "Email confirmation code" msgstr "" +#: ../browser/send_mail_template_table.pt:18 +msgid "Field" +msgstr "" + #: ../captcha/recaptcha.py:12 msgid "Google ReCaptcha" msgstr "Google ReCaptcha" @@ -57,6 +61,10 @@ msgstr "Soporte de NoRobots ReCaptcha" msgid "OTP is wrong" msgstr "" +#: ../browser/templates/email_confirm_view.pt:17 +msgid "Simple Transactional Email" +msgstr "" + #: ../captcha/hcaptcha.py:56 #: ../captcha/norobots.py:65 #: ../captcha/recaptcha.py:54 @@ -87,6 +95,10 @@ msgstr "" msgid "Uninstalls the collective.volto.formsupport add-on." msgstr "Desinstala o complemento collective.volto.formsupport." +#: ../browser/send_mail_template_table.pt:23 +msgid "Value" +msgstr "" + #: ../configure.zcml:34 msgid "Volto: Form support" msgstr "Volto: Soporte a formularios" @@ -100,17 +112,17 @@ msgid "Your code to validate the email address:" msgstr "" #. Default: "Attachments too big. You uploaded ${uploaded_str}, but limit is ${max} MB. Try to compress files." -#: ../restapi/services/submit_form/post.py:215 +#: ../restapi/services/submit_form/post.py:234 msgid "attachments_too_big" msgstr "Adjuntos demasiado grandes. Subiste el archivo ${uploaded_str}, pero el límite es de ${max} MB. Intenta comprimir archivos." #. Default: "Block with @type \"form\" and id \"$block\" not found in this context: $context" -#: ../restapi/services/submit_form/post.py:130 +#: ../restapi/services/submit_form/post.py:149 msgid "block_form_not_found_label" msgstr "Bloque con @type \"form\" y id \"${block}\" no encontrado en contexto: $context." #. Default: "Empty form data." -#: ../restapi/services/submit_form/post.py:156 +#: ../restapi/services/submit_form/post.py:175 msgid "empty_form_data" msgstr "Formulario sem dados." @@ -119,23 +131,30 @@ msgstr "Formulario sem dados." msgid "honeypot_error" msgstr "" -#. Default: "Unable to send confirm email. Please retry later or contact site administator." -#: ../restapi/services/submit_form/post.py:76 +#. Default: "Unable to send confirm email. Please retry later or contact site administrator." +#: ../restapi/services/submit_form/post.py:82 +#, fuzzy msgid "mail_send_exception" msgstr "No se puede enviar el correo electrónico de confirmación. Vuelva a intentarlo más tarde o póngase en contacto con el administrador del sitio." #. Default: "You need to set at least one form action between \"send\" and \"store\"." -#: ../restapi/services/submit_form/post.py:145 +#: ../restapi/services/submit_form/post.py:164 msgid "missing_action" msgstr "Debe seleccionar al menos una acción entre \"guardar\" y \"enviar\"." #. Default: "Missing block_id" -#: ../restapi/services/submit_form/post.py:123 +#: ../restapi/services/submit_form/post.py:142 msgid "missing_blockid_label" msgstr "Campo block_id no informado" -#. Default: "A new form has been submitted from ${url}" -#: ../browser/send_mail_template.pt:22 +#. Default: "Unable to save data. Value not unique: '${fields}'" +#: ../restapi/services/submit_form/post.py:96 +msgid "save_data_exception" +msgstr "" + +#. Default: "A new form has been submitted from ${url}" +#: ../browser/send_mail_template.pt:24 +#, fuzzy msgid "send_mail_text" msgstr "Se ha enviado un nuevo formulario desde ${url}:" @@ -145,15 +164,15 @@ msgid "send_mail_text_table" msgstr "" #. Default: "Missing required field: subject or from." -#: ../restapi/services/submit_form/post.py:322 +#: ../restapi/services/submit_form/post.py:341 msgid "send_required_field_missing" msgstr "Campo obligatorio no presente: Asunto o remitente." #. Default: "Email not valid in \"${field}\" field." -#: ../restapi/services/submit_form/post.py:187 +#: ../restapi/services/submit_form/post.py:206 msgid "wrong_email" msgstr "" -#: ../restapi/services/submit_form/post.py:246 +#: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "" diff --git a/src/collective/volto/formsupport/locales/it/LC_MESSAGES/collective.volto.formsupport.po b/src/collective/volto/formsupport/locales/it/LC_MESSAGES/collective.volto.formsupport.po index ea816f33..48a2d732 100644 --- a/src/collective/volto/formsupport/locales/it/LC_MESSAGES/collective.volto.formsupport.po +++ b/src/collective/volto/formsupport/locales/it/LC_MESSAGES/collective.volto.formsupport.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-06-07 00:42+0000\n" +"POT-Creation-Date: 2024-06-25 10:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,6 +18,10 @@ msgstr "" msgid "Email confirmation code" msgstr "Codice di conferma dell'email" +#: ../browser/send_mail_template_table.pt:18 +msgid "Field" +msgstr "" + #: ../captcha/recaptcha.py:12 msgid "Google ReCaptcha" msgstr "Google ReCaptcha" @@ -52,6 +56,10 @@ msgstr "NoRobots" msgid "OTP is wrong" msgstr "Il codice OTP è errato." +#: ../browser/templates/email_confirm_view.pt:17 +msgid "Simple Transactional Email" +msgstr "" + #: ../captcha/hcaptcha.py:56 #: ../captcha/norobots.py:65 #: ../captcha/recaptcha.py:54 @@ -82,6 +90,10 @@ msgstr "Campo uid è mancante" msgid "Uninstalls the collective.volto.formsupport add-on." msgstr "Disinstalla collective.volto.formsupport." +#: ../browser/send_mail_template_table.pt:23 +msgid "Value" +msgstr "" + #: ../configure.zcml:34 msgid "Volto: Form support" msgstr "Volto: Form support" @@ -95,17 +107,17 @@ msgid "Your code to validate the email address:" msgstr "Il tuo codice per la conferma dell'indirizzo email:" #. Default: "Attachments too big. You uploaded ${uploaded_str}, but limit is ${max} MB. Try to compress files." -#: ../restapi/services/submit_form/post.py:215 +#: ../restapi/services/submit_form/post.py:234 msgid "attachments_too_big" msgstr "Allegati troppo grandi. Hai caricato ${uploaded_str}, ma il limite è di ${max} MB. Prova a comprimerli." #. Default: "Block with @type \"form\" and id \"$block\" not found in this context: $context" -#: ../restapi/services/submit_form/post.py:130 +#: ../restapi/services/submit_form/post.py:149 msgid "block_form_not_found_label" msgstr "Blocco con @type \"form\" e id \"$block\" non trovato nel contesto: $context" #. Default: "Empty form data." -#: ../restapi/services/submit_form/post.py:156 +#: ../restapi/services/submit_form/post.py:175 msgid "empty_form_data" msgstr "Form senza dati." @@ -114,23 +126,30 @@ msgstr "Form senza dati." msgid "honeypot_error" msgstr "Errore nella sottomissione del form." -#. Default: "Unable to send confirm email. Please retry later or contact site administator." -#: ../restapi/services/submit_form/post.py:76 +#. Default: "Unable to send confirm email. Please retry later or contact site administrator." +#: ../restapi/services/submit_form/post.py:82 +#, fuzzy msgid "mail_send_exception" msgstr "Impossibile inviare la mail di conferma. Per favore riprova più tardi o contatta l'amministratore del sito." #. Default: "You need to set at least one form action between \"send\" and \"store\"." -#: ../restapi/services/submit_form/post.py:145 +#: ../restapi/services/submit_form/post.py:164 msgid "missing_action" msgstr "Devi selezionare almeno un'azione tra \"salva\" e \"invia\"." #. Default: "Missing block_id" -#: ../restapi/services/submit_form/post.py:123 +#: ../restapi/services/submit_form/post.py:142 msgid "missing_blockid_label" msgstr "Campo block_id mancante." -#. Default: "A new form has been submitted from ${url}" -#: ../browser/send_mail_template.pt:22 +#. Default: "Unable to save data. Value not unique: '${fields}'" +#: ../restapi/services/submit_form/post.py:96 +msgid "save_data_exception" +msgstr "Impossibile salvare i dati. I campi '${fields}' non sono univoci." + +#. Default: "A new form has been submitted from ${url}" +#: ../browser/send_mail_template.pt:24 +#, fuzzy msgid "send_mail_text" msgstr "Modulo compilato su ${url}" @@ -140,15 +159,15 @@ msgid "send_mail_text_table" msgstr "Dati inviati per ${title}" #. Default: "Missing required field: subject or from." -#: ../restapi/services/submit_form/post.py:322 +#: ../restapi/services/submit_form/post.py:341 msgid "send_required_field_missing" msgstr "Campo obbligatorio mancante: subject o from." #. Default: "Email not valid in \"${field}\" field." -#: ../restapi/services/submit_form/post.py:187 +#: ../restapi/services/submit_form/post.py:206 msgid "wrong_email" msgstr "Email inserita non valida nel campo \"${field}\"." -#: ../restapi/services/submit_form/post.py:246 +#: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "Il codice OTP per {email} è errato." diff --git a/src/collective/volto/formsupport/locales/pt_BR/LC_MESSAGES/collective.volto.formsupport.po b/src/collective/volto/formsupport/locales/pt_BR/LC_MESSAGES/collective.volto.formsupport.po index d6d345a4..f8e9d25c 100644 --- a/src/collective/volto/formsupport/locales/pt_BR/LC_MESSAGES/collective.volto.formsupport.po +++ b/src/collective/volto/formsupport/locales/pt_BR/LC_MESSAGES/collective.volto.formsupport.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2024-06-07 00:42+0000\n" +"POT-Creation-Date: 2024-06-25 10:15+0000\n" "PO-Revision-Date: 2021-05-11 18:49-0300\n" "Last-Translator: Érico Andrei , 2021\n" "Language-Team: Portuguese (https://www.transifex.com/plone/teams/14552/pt/)\n" @@ -20,6 +20,10 @@ msgstr "" msgid "Email confirmation code" msgstr "" +#: ../browser/send_mail_template_table.pt:18 +msgid "Field" +msgstr "" + #: ../captcha/recaptcha.py:12 msgid "Google ReCaptcha" msgstr "" @@ -54,6 +58,10 @@ msgstr "" msgid "OTP is wrong" msgstr "" +#: ../browser/templates/email_confirm_view.pt:17 +msgid "Simple Transactional Email" +msgstr "" + #: ../captcha/hcaptcha.py:56 #: ../captcha/norobots.py:65 #: ../captcha/recaptcha.py:54 @@ -84,6 +92,10 @@ msgstr "" msgid "Uninstalls the collective.volto.formsupport add-on." msgstr "Desinstala o complemento collective.volto.formsupport." +#: ../browser/send_mail_template_table.pt:23 +msgid "Value" +msgstr "" + #: ../configure.zcml:34 msgid "Volto: Form support" msgstr "Volto: Suporte a formulários" @@ -97,17 +109,17 @@ msgid "Your code to validate the email address:" msgstr "" #. Default: "Attachments too big. You uploaded ${uploaded_str}, but limit is ${max} MB. Try to compress files." -#: ../restapi/services/submit_form/post.py:215 +#: ../restapi/services/submit_form/post.py:234 msgid "attachments_too_big" msgstr "" #. Default: "Block with @type \"form\" and id \"$block\" not found in this context: $context" -#: ../restapi/services/submit_form/post.py:130 +#: ../restapi/services/submit_form/post.py:149 msgid "block_form_not_found_label" msgstr "Bloco com @type \"form\" e id \"${block}\" não encontrado no contexto: $context." #. Default: "Empty form data." -#: ../restapi/services/submit_form/post.py:156 +#: ../restapi/services/submit_form/post.py:175 msgid "empty_form_data" msgstr "Formulário sem dados." @@ -116,23 +128,29 @@ msgstr "Formulário sem dados." msgid "honeypot_error" msgstr "" -#. Default: "Unable to send confirm email. Please retry later or contact site administator." -#: ../restapi/services/submit_form/post.py:76 +#. Default: "Unable to send confirm email. Please retry later or contact site administrator." +#: ../restapi/services/submit_form/post.py:82 msgid "mail_send_exception" msgstr "" #. Default: "You need to set at least one form action between \"send\" and \"store\"." -#: ../restapi/services/submit_form/post.py:145 +#: ../restapi/services/submit_form/post.py:164 msgid "missing_action" msgstr "Você deve selecionar pelo menos uma ação entre \"salvar\" e \"enviar\"." #. Default: "Missing block_id" -#: ../restapi/services/submit_form/post.py:123 +#: ../restapi/services/submit_form/post.py:142 msgid "missing_blockid_label" msgstr "Campo block_id não informado" -#. Default: "A new form has been submitted from ${url}" -#: ../browser/send_mail_template.pt:22 +#. Default: "Unable to save data. Value not unique: '${fields}'" +#: ../restapi/services/submit_form/post.py:96 +msgid "save_data_exception" +msgstr "" + +#. Default: "A new form has been submitted from ${url}" +#: ../browser/send_mail_template.pt:24 +#, fuzzy msgid "send_mail_text" msgstr "Um novo formulário foi preenchido em ${url}:" @@ -142,15 +160,15 @@ msgid "send_mail_text_table" msgstr "" #. Default: "Missing required field: subject or from." -#: ../restapi/services/submit_form/post.py:322 +#: ../restapi/services/submit_form/post.py:341 msgid "send_required_field_missing" msgstr "Campo obrigatório não presente: Assunto ou remetente." #. Default: "Email not valid in \"${field}\" field." -#: ../restapi/services/submit_form/post.py:187 +#: ../restapi/services/submit_form/post.py:206 msgid "wrong_email" msgstr "" -#: ../restapi/services/submit_form/post.py:246 +#: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "" diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py index 8299aa17..dd29ab5c 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -95,7 +95,8 @@ def reply(self): message = translate( _( "save_data_exception", - default=f"Unable to save data. Value not unique: {e.args[0]}", + default="Unable to save data. Value not unique: '${fields}'", + mapping={"fields": e.args[0]}, ), context=self.request, ) From 8165fea731053801b8c117e9f920cbcabf457625 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Tue, 25 Jun 2024 12:24:05 +0200 Subject: [PATCH 11/14] fix: fixed waiting_list column name in csv export --- .../volto/formsupport/restapi/services/form_data/csv.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index 68d5b26a..bd240675 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -70,7 +70,7 @@ def get_data(self): if self.form_block.get("limit", None) is not None: limit = int(self.form_block["limit"]) if limit > -1: - custom_colums.append("Lista d'attesa") + custom_colums.append("waiting_list") rows = [] for index, item in enumerate(store.search()): @@ -88,8 +88,8 @@ def get_data(self): # add fixed columns values value = item.attrs.get(k, None) data[k] = json_compatible(value) - if "Lista d'attesa" in custom_colums: - data.update({"Lista d'attesa": not (index < limit)}) + if "waiting_list" in custom_colums: + data.update({"waiting_list": not (index < limit)}) rows.append(data) columns.extend(fixed_columns) From 3872934b02946164c773a96c789dda5990443a48 Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Tue, 25 Jun 2024 17:16:34 +0200 Subject: [PATCH 12/14] fix: changed label for waiting_list --- .../volto/formsupport/restapi/services/form_data/csv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index bd240675..d54766eb 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -89,7 +89,7 @@ def get_data(self): value = item.attrs.get(k, None) data[k] = json_compatible(value) if "waiting_list" in custom_colums: - data.update({"waiting_list": not (index < limit)}) + data.update({"waiting_list": "Sì" if not (index < limit) else "No"}) rows.append(data) columns.extend(fixed_columns) From 524aeba8e6a456655be5d81ac339b97a0fd01b5c Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Tue, 25 Jun 2024 17:22:23 +0200 Subject: [PATCH 13/14] chore: add translation --- .../locales/collective.volto.formsupport.pot | 12 +++++++++++- .../de/LC_MESSAGES/collective.volto.formsupport.po | 12 +++++++++++- .../es/LC_MESSAGES/collective.volto.formsupport.po | 12 +++++++++++- .../it/LC_MESSAGES/collective.volto.formsupport.po | 12 +++++++++++- .../LC_MESSAGES/collective.volto.formsupport.po | 12 +++++++++++- .../formsupport/restapi/services/form_data/csv.py | 12 +++++++++++- 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/collective/volto/formsupport/locales/collective.volto.formsupport.pot b/src/collective/volto/formsupport/locales/collective.volto.formsupport.pot index 9234da8e..44c90f8b 100644 --- a/src/collective/volto/formsupport/locales/collective.volto.formsupport.pot +++ b/src/collective/volto/formsupport/locales/collective.volto.formsupport.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-06-25 10:15+0000\n" +"POT-Creation-Date: 2024-06-25 15:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -144,6 +144,11 @@ msgstr "" msgid "missing_blockid_label" msgstr "" +#. Default: "No" +#: ../restapi/services/form_data/csv.py:99 +msgid "no_label" +msgstr "" + #. Default: "Unable to save data. Value not unique: '${fields}'" #: ../restapi/services/submit_form/post.py:96 msgid "save_data_exception" @@ -169,6 +174,11 @@ msgstr "" msgid "wrong_email" msgstr "" +#. Default: "Yes" +#: ../restapi/services/form_data/csv.py:97 +msgid "yes_label" +msgstr "" + #: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "" diff --git a/src/collective/volto/formsupport/locales/de/LC_MESSAGES/collective.volto.formsupport.po b/src/collective/volto/formsupport/locales/de/LC_MESSAGES/collective.volto.formsupport.po index d91dd493..38deb86f 100644 --- a/src/collective/volto/formsupport/locales/de/LC_MESSAGES/collective.volto.formsupport.po +++ b/src/collective/volto/formsupport/locales/de/LC_MESSAGES/collective.volto.formsupport.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-06-25 10:15+0000\n" +"POT-Creation-Date: 2024-06-25 15:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -142,6 +142,11 @@ msgstr "Es muss mindestens eine Formular-Aktion gesetzt werden (\"E-Mail an Empf msgid "missing_blockid_label" msgstr "Fehlende block_id" +#. Default: "No" +#: ../restapi/services/form_data/csv.py:99 +msgid "no_label" +msgstr "" + #. Default: "Unable to save data. Value not unique: '${fields}'" #: ../restapi/services/submit_form/post.py:96 msgid "save_data_exception" @@ -168,6 +173,11 @@ msgstr "Erforderliches Feld fehlt: Betreff oder Absender" msgid "wrong_email" msgstr "" +#. Default: "Yes" +#: ../restapi/services/form_data/csv.py:97 +msgid "yes_label" +msgstr "" + #: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "" diff --git a/src/collective/volto/formsupport/locales/es/LC_MESSAGES/collective.volto.formsupport.po b/src/collective/volto/formsupport/locales/es/LC_MESSAGES/collective.volto.formsupport.po index b7d32a85..77adf7eb 100644 --- a/src/collective/volto/formsupport/locales/es/LC_MESSAGES/collective.volto.formsupport.po +++ b/src/collective/volto/formsupport/locales/es/LC_MESSAGES/collective.volto.formsupport.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: collective.volto.formsupport\n" -"POT-Creation-Date: 2024-06-25 10:15+0000\n" +"POT-Creation-Date: 2024-06-25 15:21+0000\n" "PO-Revision-Date: 2023-05-11 10:11-0400\n" "Last-Translator: Leonardo J. Caballero G. \n" "Language-Team: ES \n" @@ -147,6 +147,11 @@ msgstr "Debe seleccionar al menos una acción entre \"guardar\" y \"enviar\"." msgid "missing_blockid_label" msgstr "Campo block_id no informado" +#. Default: "No" +#: ../restapi/services/form_data/csv.py:99 +msgid "no_label" +msgstr "" + #. Default: "Unable to save data. Value not unique: '${fields}'" #: ../restapi/services/submit_form/post.py:96 msgid "save_data_exception" @@ -173,6 +178,11 @@ msgstr "Campo obligatorio no presente: Asunto o remitente." msgid "wrong_email" msgstr "" +#. Default: "Yes" +#: ../restapi/services/form_data/csv.py:97 +msgid "yes_label" +msgstr "" + #: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "" diff --git a/src/collective/volto/formsupport/locales/it/LC_MESSAGES/collective.volto.formsupport.po b/src/collective/volto/formsupport/locales/it/LC_MESSAGES/collective.volto.formsupport.po index 48a2d732..73b703fa 100644 --- a/src/collective/volto/formsupport/locales/it/LC_MESSAGES/collective.volto.formsupport.po +++ b/src/collective/volto/formsupport/locales/it/LC_MESSAGES/collective.volto.formsupport.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-06-25 10:15+0000\n" +"POT-Creation-Date: 2024-06-25 15:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -142,6 +142,11 @@ msgstr "Devi selezionare almeno un'azione tra \"salva\" e \"invia\"." msgid "missing_blockid_label" msgstr "Campo block_id mancante." +#. Default: "No" +#: ../restapi/services/form_data/csv.py:99 +msgid "no_label" +msgstr "No" + #. Default: "Unable to save data. Value not unique: '${fields}'" #: ../restapi/services/submit_form/post.py:96 msgid "save_data_exception" @@ -168,6 +173,11 @@ msgstr "Campo obbligatorio mancante: subject o from." msgid "wrong_email" msgstr "Email inserita non valida nel campo \"${field}\"." +#. Default: "Yes" +#: ../restapi/services/form_data/csv.py:97 +msgid "yes_label" +msgstr "Sì" + #: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "Il codice OTP per {email} è errato." diff --git a/src/collective/volto/formsupport/locales/pt_BR/LC_MESSAGES/collective.volto.formsupport.po b/src/collective/volto/formsupport/locales/pt_BR/LC_MESSAGES/collective.volto.formsupport.po index f8e9d25c..d66f9c8c 100644 --- a/src/collective/volto/formsupport/locales/pt_BR/LC_MESSAGES/collective.volto.formsupport.po +++ b/src/collective/volto/formsupport/locales/pt_BR/LC_MESSAGES/collective.volto.formsupport.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2024-06-25 10:15+0000\n" +"POT-Creation-Date: 2024-06-25 15:21+0000\n" "PO-Revision-Date: 2021-05-11 18:49-0300\n" "Last-Translator: Érico Andrei , 2021\n" "Language-Team: Portuguese (https://www.transifex.com/plone/teams/14552/pt/)\n" @@ -143,6 +143,11 @@ msgstr "Você deve selecionar pelo menos uma ação entre \"salvar\" e \"enviar\ msgid "missing_blockid_label" msgstr "Campo block_id não informado" +#. Default: "No" +#: ../restapi/services/form_data/csv.py:99 +msgid "no_label" +msgstr "" + #. Default: "Unable to save data. Value not unique: '${fields}'" #: ../restapi/services/submit_form/post.py:96 msgid "save_data_exception" @@ -169,6 +174,11 @@ msgstr "Campo obrigatório não presente: Assunto ou remetente." msgid "wrong_email" msgstr "" +#. Default: "Yes" +#: ../restapi/services/form_data/csv.py:97 +msgid "yes_label" +msgstr "" + #: ../restapi/services/submit_form/post.py:265 msgid "{email}'s OTP is wrong" msgstr "" diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index d54766eb..22c3f65e 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -1,8 +1,10 @@ +from collective.volto.formsupport import _ from collective.volto.formsupport.interfaces import IFormDataStore from io import StringIO from plone.restapi.serializer.converters import json_compatible from plone.restapi.services import Service from zope.component import getMultiAdapter +from zope.i18n import translate import csv @@ -89,7 +91,15 @@ def get_data(self): value = item.attrs.get(k, None) data[k] = json_compatible(value) if "waiting_list" in custom_colums: - data.update({"waiting_list": "Sì" if not (index < limit) else "No"}) + data.update( + { + "waiting_list": ( + translate(_("yes_label", default="Yes")) + if not (index < limit) + else translate(_("no_label", default="No")) + ) + } + ) rows.append(data) columns.extend(fixed_columns) From a697b20f01d0cf3bfe09fa557e3ebf2268ba7f8b Mon Sep 17 00:00:00 2001 From: Filippo Campi Date: Wed, 26 Jun 2024 18:19:10 +0200 Subject: [PATCH 14/14] [doc][dev] add a custom class for duplicate value exception + add some documentation --- CHANGES.rst | 4 ++++ README.rst | 6 ++++++ src/collective/volto/formsupport/datamanager/catalog.py | 3 ++- src/collective/volto/formsupport/utils.py | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index afe02df7..884abbae 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,10 @@ Changelog - Handle the edge cases where the `blocks` attribute is not set. [mamico] +- Added support for field limit that limits form submission and the exceeding ones are added to a waiting list. + [eikichi18] +- Added support to make one or more fields unique. + [eikichi18] 3.0.2 (2024-05-05) diff --git a/README.rst b/README.rst index 0986b382..5dea0258 100644 --- a/README.rst +++ b/README.rst @@ -177,6 +177,12 @@ Each Record stores also two *service* attributes: We store these attributes because the form can change over time and we want to have a snapshot of the fields in the Record. +With the store function we have added a function to limit the number of submits made for a form. +This function is based on the use case of, for example, reserved place for a private lessons. +Beyond a certain limit the date are marked with waiting_list True. + +We have also added the function to make one or more fields of the form unique. + Data ID Mapping ^^^^^^^^^^^^^^^ diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index 2d825451..3bbe56cc 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -1,5 +1,6 @@ from collective.volto.formsupport import logger from collective.volto.formsupport.interfaces import IFormDataStore +from collective.volto.formsupport.utils import DuplicateValueError from collective.volto.formsupport.utils import get_blocks from copy import deepcopy from datetime import datetime @@ -113,7 +114,7 @@ def add(self, data): break if not unique: - raise ValueError(f" {', '.join([x[1] for x in keys])}") + raise DuplicateValueError(f" {', '.join([x[1] for x in keys])}") return self.soup.add(record) diff --git a/src/collective/volto/formsupport/utils.py b/src/collective/volto/formsupport/utils.py index f98e21fa..bb8c0dd1 100644 --- a/src/collective/volto/formsupport/utils.py +++ b/src/collective/volto/formsupport/utils.py @@ -11,6 +11,10 @@ EMAIL_OTP_LIFETIME = 5 * 60 +class DuplicateValueError(ValueError): + pass + + def flatten_block_hierachy(blocks): """Given some blocks, return all contained blocks, including "subblocks" This allows embedding the form block into something like columns datastorage