From 69e1a14bfcde29cace67893374a3918ba78db9cf Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Fri, 15 Apr 2022 15:34:48 +0200 Subject: [PATCH 01/16] [REF] Split cooperator_website into cooperator_website_recaptcha Signed-off-by: Carmen Bianca Bakker --- cooperator_website_recaptcha/__init__.py | 2 + cooperator_website_recaptcha/__manifest__.py | 25 +++++++++++ .../controllers/__init__.py | 1 + .../controllers/main.py | 43 +++++++++++++++++++ .../models/__init__.py | 1 + .../models/res_company.py | 11 +++++ .../readme/CONTRIBUTORS.rst | 3 ++ .../readme/DESCRIPTION.rst | 0 .../views/res_company_views.xml | 13 ++++++ .../views/subscription_template.xml | 34 +++++++++++++++ .../odoo/addons/cooperator_website_recaptcha | 1 + setup/cooperator_website_recaptcha/setup.py | 6 +++ 12 files changed, 140 insertions(+) create mode 100644 cooperator_website_recaptcha/__init__.py create mode 100644 cooperator_website_recaptcha/__manifest__.py create mode 100644 cooperator_website_recaptcha/controllers/__init__.py create mode 100644 cooperator_website_recaptcha/controllers/main.py create mode 100644 cooperator_website_recaptcha/models/__init__.py create mode 100644 cooperator_website_recaptcha/models/res_company.py create mode 100644 cooperator_website_recaptcha/readme/CONTRIBUTORS.rst create mode 100644 cooperator_website_recaptcha/readme/DESCRIPTION.rst create mode 100644 cooperator_website_recaptcha/views/res_company_views.xml create mode 100644 cooperator_website_recaptcha/views/subscription_template.xml create mode 120000 setup/cooperator_website_recaptcha/odoo/addons/cooperator_website_recaptcha create mode 100644 setup/cooperator_website_recaptcha/setup.py diff --git a/cooperator_website_recaptcha/__init__.py b/cooperator_website_recaptcha/__init__.py new file mode 100644 index 000000000..91c5580fe --- /dev/null +++ b/cooperator_website_recaptcha/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py new file mode 100644 index 000000000..7cc3361ac --- /dev/null +++ b/cooperator_website_recaptcha/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2022 Coop IT Easy SCRLfs +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Cooperators Website Recaptcha", + "summary": """ + TODO""", + "version": "12.0.1.0.0", + "category": "Cooperative management", + "website": "https://coopiteasy.be", + "author": "Coop IT Easy SCRLfs", + "license": "AGPL-3", + "application": False, + "depends": [ + "cooperator_website", + "portal_recaptcha", + ], + "excludes": [], + "data": [ + "views/res_company_views.xml", + "views/subscription_template.xml", + ], + "demo": [], + "qweb": [], +} diff --git a/cooperator_website_recaptcha/controllers/__init__.py b/cooperator_website_recaptcha/controllers/__init__.py new file mode 100644 index 000000000..12a7e529b --- /dev/null +++ b/cooperator_website_recaptcha/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/cooperator_website_recaptcha/controllers/main.py b/cooperator_website_recaptcha/controllers/main.py new file mode 100644 index 000000000..908fa138e --- /dev/null +++ b/cooperator_website_recaptcha/controllers/main.py @@ -0,0 +1,43 @@ +from odoo.http import request +from odoo.tools.translate import _ + +from odoo.addons.cooperator_website.controllers.main import WebsiteSubscription + + +class RecaptchaWebsiteSubscription(WebsiteSubscription): + def validation( # noqa: C901 (method too complex) + self, kwargs, logged, values, post_file + ): + result = super().validation(kwargs, logged, values, post_file) + if result is not True: + return result + + redirect = "cooperator_website.becomecooperator" + + is_company = kwargs.get("is_company") == "on" + + # TODO: Use a overloaded function with the captcha implementation + if request.env["res.company"].captcha_type == "google": + if ( + "g-recaptcha-response" not in kwargs + or kwargs["g-recaptcha-response"] == "" + ): + values = self.fill_values(values, is_company, logged) + values.update(kwargs) + values["error_msg"] = _( + "the captcha has not been validated," " please fill in the captcha" + ) + + return request.render(redirect, values) + elif not request.env["portal.mixin"].is_captcha_valid( + kwargs["g-recaptcha-response"] + ): + values = self.fill_values(values, is_company, logged) + values.update(kwargs) + values["error_msg"] = _( + "the captcha has not been validated," " please fill in the captcha" + ) + + return request.render(redirect, values) + + return True diff --git a/cooperator_website_recaptcha/models/__init__.py b/cooperator_website_recaptcha/models/__init__.py new file mode 100644 index 000000000..aff44f335 --- /dev/null +++ b/cooperator_website_recaptcha/models/__init__.py @@ -0,0 +1 @@ +from . import res_company diff --git a/cooperator_website_recaptcha/models/res_company.py b/cooperator_website_recaptcha/models/res_company.py new file mode 100644 index 000000000..355b2297f --- /dev/null +++ b/cooperator_website_recaptcha/models/res_company.py @@ -0,0 +1,11 @@ +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + captcha_type = fields.Selection( + [("none", "Disabled"), ("google", "Google Recaptcha")], + "Captcha type or disabled", + required=True, + default="google", + ) diff --git a/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst b/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9f39efbc5 --- /dev/null +++ b/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Coop IT Easy SCRLfs `_: + + * Carmen Bianca Bakker diff --git a/cooperator_website_recaptcha/readme/DESCRIPTION.rst b/cooperator_website_recaptcha/readme/DESCRIPTION.rst new file mode 100644 index 000000000..e69de29bb diff --git a/cooperator_website_recaptcha/views/res_company_views.xml b/cooperator_website_recaptcha/views/res_company_views.xml new file mode 100644 index 000000000..42b81e88c --- /dev/null +++ b/cooperator_website_recaptcha/views/res_company_views.xml @@ -0,0 +1,13 @@ + + + + res.company.form.captcha + + res.company + + + + + + + diff --git a/cooperator_website_recaptcha/views/subscription_template.xml b/cooperator_website_recaptcha/views/subscription_template.xml new file mode 100644 index 000000000..16994f150 --- /dev/null +++ b/cooperator_website_recaptcha/views/subscription_template.xml @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/setup/cooperator_website_recaptcha/odoo/addons/cooperator_website_recaptcha b/setup/cooperator_website_recaptcha/odoo/addons/cooperator_website_recaptcha new file mode 120000 index 000000000..957701f6c --- /dev/null +++ b/setup/cooperator_website_recaptcha/odoo/addons/cooperator_website_recaptcha @@ -0,0 +1 @@ +../../../../cooperator_website_recaptcha \ No newline at end of file diff --git a/setup/cooperator_website_recaptcha/setup.py b/setup/cooperator_website_recaptcha/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/cooperator_website_recaptcha/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From cbc5f878766d005248301d1e214154f1ed0fd843 Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Mon, 23 May 2022 08:14:10 +0000 Subject: [PATCH 02/16] [UPD] Update cooperator_website_recaptcha.pot --- .../i18n/cooperator_website_recaptcha.pot | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot diff --git a/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot b/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot new file mode 100644 index 000000000..254049ab2 --- /dev/null +++ b/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * cooperator_website_recaptcha +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: cooperator_website_recaptcha +#: model:ir.model,name:cooperator_website_recaptcha.model_res_company +msgid "Companies" +msgstr "" + From 6070c3b4daf9ec41faeda43e7b1f674d01fe7610 Mon Sep 17 00:00:00 2001 From: oca-ci Date: Wed, 1 Jun 2022 10:10:23 +0200 Subject: [PATCH 03/16] [UPD] Update cooperator_website_recaptcha.pot --- .../i18n/cooperator_website_recaptcha.pot | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot b/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot index 254049ab2..02f6c1a73 100644 --- a/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot +++ b/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot @@ -13,8 +13,30 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: cooperator_website_recaptcha +#: model:ir.model.fields,field_description:cooperator_website_recaptcha.field_res_company__captcha_type +msgid "Captcha type or disabled" +msgstr "" + #. module: cooperator_website_recaptcha #: model:ir.model,name:cooperator_website_recaptcha.model_res_company msgid "Companies" msgstr "" +#. module: cooperator_website_recaptcha +#: selection:res.company,captcha_type:0 +msgid "Disabled" +msgstr "" + +#. module: cooperator_website_recaptcha +#: selection:res.company,captcha_type:0 +msgid "Google Recaptcha" +msgstr "" + +#. module: cooperator_website_recaptcha +#: code:addons/cooperator_website_recaptcha/controllers/main.py:27 +#: code:addons/cooperator_website_recaptcha/controllers/main.py:37 +#, python-format +msgid "the captcha has not been validated, please fill in the captcha" +msgstr "" + From 6fbae129e62345b28444db86e35520637f789f44 Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Tue, 10 May 2022 13:38:08 +0200 Subject: [PATCH 04/16] [FIX] template call in become_cooperator --- cooperator_website_recaptcha/views/subscription_template.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cooperator_website_recaptcha/views/subscription_template.xml b/cooperator_website_recaptcha/views/subscription_template.xml index 16994f150..bb9eac345 100644 --- a/cooperator_website_recaptcha/views/subscription_template.xml +++ b/cooperator_website_recaptcha/views/subscription_template.xml @@ -17,7 +17,7 @@ name="Become Cooperator" > - + @@ -27,7 +27,7 @@ name="Become Cooperator" > - + From 6f59018a29898aa81a5f1709c41496c69647a79b Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Tue, 10 May 2022 16:26:37 +0200 Subject: [PATCH 05/16] [ADD] description to cooperator_website_recaptcha --- cooperator_website_recaptcha/__manifest__.py | 2 +- cooperator_website_recaptcha/readme/DESCRIPTION.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index 7cc3361ac..1adcb6a56 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Cooperators Website Recaptcha", "summary": """ - TODO""", + Add Google Recaptcha to Subscription Request Form""", "version": "12.0.1.0.0", "category": "Cooperative management", "website": "https://coopiteasy.be", diff --git a/cooperator_website_recaptcha/readme/DESCRIPTION.rst b/cooperator_website_recaptcha/readme/DESCRIPTION.rst index e69de29bb..e2d9bce47 100644 --- a/cooperator_website_recaptcha/readme/DESCRIPTION.rst +++ b/cooperator_website_recaptcha/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Add Google Recaptcha to Subscription Request Form From 49ed57b7ef196be5a554c61cdb49f6410025455b Mon Sep 17 00:00:00 2001 From: Github GRAP Bot Date: Thu, 23 Jun 2022 14:51:47 +0000 Subject: [PATCH 06/16] [UPD] README.rst --- cooperator_website_recaptcha/README.rst | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 cooperator_website_recaptcha/README.rst diff --git a/cooperator_website_recaptcha/README.rst b/cooperator_website_recaptcha/README.rst new file mode 100644 index 000000000..cafdb2dbd --- /dev/null +++ b/cooperator_website_recaptcha/README.rst @@ -0,0 +1,59 @@ +============================= +Cooperators Website Recaptcha +============================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Fvertical--cooperative-lightgray.png?logo=github + :target: https://github.com/coopiteasy/vertical-cooperative/tree/12.0/cooperator_website_recaptcha + :alt: coopiteasy/vertical-cooperative + +|badge1| |badge2| |badge3| + +Add Google Recaptcha to Subscription Request Form + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Coop IT Easy SCRLfs + +Contributors +~~~~~~~~~~~~ + +* `Coop IT Easy SCRLfs `_: + + * Carmen Bianca Bakker + +Maintainers +~~~~~~~~~~~ + +This module is part of the `coopiteasy/vertical-cooperative `_ project on GitHub. + +You are welcome to contribute. From ff36d3652bcc94a6959b65ed99b37b9f4151983d Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Wed, 29 Jun 2022 11:20:24 +0200 Subject: [PATCH 07/16] =?UTF-8?q?[FIX]=20SCRLfs=20=E2=86=92=20SC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carmen Bianca Bakker --- cooperator_website_recaptcha/README.rst | 4 ++-- cooperator_website_recaptcha/__manifest__.py | 4 ++-- cooperator_website_recaptcha/readme/CONTRIBUTORS.rst | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cooperator_website_recaptcha/README.rst b/cooperator_website_recaptcha/README.rst index cafdb2dbd..a0f54e705 100644 --- a/cooperator_website_recaptcha/README.rst +++ b/cooperator_website_recaptcha/README.rst @@ -42,12 +42,12 @@ Credits Authors ~~~~~~~ -* Coop IT Easy SCRLfs +* Coop IT Easy SC Contributors ~~~~~~~~~~~~ -* `Coop IT Easy SCRLfs `_: +* `Coop IT Easy SC `_: * Carmen Bianca Bakker diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index 1adcb6a56..6fa08bbbd 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -1,4 +1,4 @@ -# Copyright 2022 Coop IT Easy SCRLfs +# Copyright 2022 Coop IT Easy SC # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { @@ -8,7 +8,7 @@ "version": "12.0.1.0.0", "category": "Cooperative management", "website": "https://coopiteasy.be", - "author": "Coop IT Easy SCRLfs", + "author": "Coop IT Easy SC", "license": "AGPL-3", "application": False, "depends": [ diff --git a/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst b/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst index 9f39efbc5..d64451edc 100644 --- a/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst +++ b/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst @@ -1,3 +1,3 @@ -* `Coop IT Easy SCRLfs `_: +* `Coop IT Easy SC `_: * Carmen Bianca Bakker From 9f95d6b3d03d98f68106939fbfc52c87f41e3d72 Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Fri, 15 Jul 2022 15:47:36 +0200 Subject: [PATCH 08/16] [MIG] cooperator_website_recaptcha: Migration to 13.0 Signed-off-by: Carmen Bianca Bakker --- cooperator_website_recaptcha/__manifest__.py | 2 +- cooperator_website_recaptcha/controllers/main.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index 6fa08bbbd..eecbae4e3 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -5,7 +5,7 @@ "name": "Cooperators Website Recaptcha", "summary": """ Add Google Recaptcha to Subscription Request Form""", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "category": "Cooperative management", "website": "https://coopiteasy.be", "author": "Coop IT Easy SC", diff --git a/cooperator_website_recaptcha/controllers/main.py b/cooperator_website_recaptcha/controllers/main.py index 908fa138e..5e048b350 100644 --- a/cooperator_website_recaptcha/controllers/main.py +++ b/cooperator_website_recaptcha/controllers/main.py @@ -25,7 +25,7 @@ def validation( # noqa: C901 (method too complex) values = self.fill_values(values, is_company, logged) values.update(kwargs) values["error_msg"] = _( - "the captcha has not been validated," " please fill in the captcha" + "the captcha has not been validated, please fill in the captcha" ) return request.render(redirect, values) @@ -35,7 +35,7 @@ def validation( # noqa: C901 (method too complex) values = self.fill_values(values, is_company, logged) values.update(kwargs) values["error_msg"] = _( - "the captcha has not been validated," " please fill in the captcha" + "the captcha has not been validated, please fill in the captcha" ) return request.render(redirect, values) From 57a9c98dee188a0e94681e0608ef417e595c7c4b Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Fri, 15 Jul 2022 15:49:20 +0200 Subject: [PATCH 09/16] [MIG] cooperator_website_recaptcha: Migration to 14.0 Signed-off-by: Carmen Bianca Bakker --- cooperator_website_recaptcha/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index eecbae4e3..f6d465c87 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -5,7 +5,7 @@ "name": "Cooperators Website Recaptcha", "summary": """ Add Google Recaptcha to Subscription Request Form""", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "category": "Cooperative management", "website": "https://coopiteasy.be", "author": "Coop IT Easy SC", From 515fc43380d261469777dcae94c061a45afd1d94 Mon Sep 17 00:00:00 2001 From: oca-ci Date: Sat, 27 Aug 2022 12:22:50 +0000 Subject: [PATCH 10/16] [UPD] Update cooperator_website_recaptcha.pot --- .../i18n/cooperator_website_recaptcha.pot | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot b/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot index 02f6c1a73..d4b382f66 100644 --- a/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot +++ b/cooperator_website_recaptcha/i18n/cooperator_website_recaptcha.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * cooperator_website_recaptcha +# * cooperator_website_recaptcha # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -24,19 +24,33 @@ msgid "Companies" msgstr "" #. module: cooperator_website_recaptcha -#: selection:res.company,captcha_type:0 +#: model:ir.model.fields.selection,name:cooperator_website_recaptcha.selection__res_company__captcha_type__none msgid "Disabled" msgstr "" #. module: cooperator_website_recaptcha -#: selection:res.company,captcha_type:0 +#: model:ir.model.fields,field_description:cooperator_website_recaptcha.field_res_company__display_name +msgid "Display Name" +msgstr "" + +#. module: cooperator_website_recaptcha +#: model:ir.model.fields.selection,name:cooperator_website_recaptcha.selection__res_company__captcha_type__google msgid "Google Recaptcha" msgstr "" #. module: cooperator_website_recaptcha -#: code:addons/cooperator_website_recaptcha/controllers/main.py:27 -#: code:addons/cooperator_website_recaptcha/controllers/main.py:37 +#: model:ir.model.fields,field_description:cooperator_website_recaptcha.field_res_company__id +msgid "ID" +msgstr "" + +#. module: cooperator_website_recaptcha +#: model:ir.model.fields,field_description:cooperator_website_recaptcha.field_res_company____last_update +msgid "Last Modified on" +msgstr "" + +#. module: cooperator_website_recaptcha +#: code:addons/cooperator_website_recaptcha/controllers/main.py:0 +#: code:addons/cooperator_website_recaptcha/controllers/main.py:0 #, python-format msgid "the captcha has not been validated, please fill in the captcha" msgstr "" - From 9c96fa7dc016b722ecbd60fdbfe50ac65abc4712 Mon Sep 17 00:00:00 2001 From: Github GRAP Bot Date: Sat, 27 Aug 2022 12:25:33 +0000 Subject: [PATCH 11/16] [UPD] README.rst --- cooperator_website_recaptcha/README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cooperator_website_recaptcha/README.rst b/cooperator_website_recaptcha/README.rst index a0f54e705..1771a8ea7 100644 --- a/cooperator_website_recaptcha/README.rst +++ b/cooperator_website_recaptcha/README.rst @@ -14,7 +14,7 @@ Cooperators Website Recaptcha :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Fvertical--cooperative-lightgray.png?logo=github - :target: https://github.com/coopiteasy/vertical-cooperative/tree/12.0/cooperator_website_recaptcha + :target: https://github.com/coopiteasy/vertical-cooperative/tree/14.0/cooperator_website_recaptcha :alt: coopiteasy/vertical-cooperative |badge1| |badge2| |badge3| @@ -32,7 +32,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -54,6 +54,6 @@ Contributors Maintainers ~~~~~~~~~~~ -This module is part of the `coopiteasy/vertical-cooperative `_ project on GitHub. +This module is part of the `coopiteasy/vertical-cooperative `_ project on GitHub. You are welcome to contribute. From 7e38e80605dd8d09e5f5418a879184b3d32e614f Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Fri, 9 Dec 2022 14:06:49 +0100 Subject: [PATCH 12/16] [REF] refactor cooperator_website_recaptcha * move the recaptcha widget view to portal_recaptcha. * remove res.company.captcha_type (portal_recaptcha can now be enabled and disabled in the settings). * override WebsiteSubscription._additional_validate() instead of .validation(). --- cooperator_website_recaptcha/__init__.py | 1 - cooperator_website_recaptcha/__manifest__.py | 12 ++---- .../controllers/main.py | 42 ++++--------------- .../migrations/14.0.1.1.0/pre-migration.py | 14 +++++++ .../models/__init__.py | 1 - .../models/res_company.py | 11 ----- .../views/res_company_views.xml | 13 ------ .../views/subscription_template.xml | 16 +------ 8 files changed, 27 insertions(+), 83 deletions(-) create mode 100644 cooperator_website_recaptcha/migrations/14.0.1.1.0/pre-migration.py delete mode 100644 cooperator_website_recaptcha/models/__init__.py delete mode 100644 cooperator_website_recaptcha/models/res_company.py delete mode 100644 cooperator_website_recaptcha/views/res_company_views.xml diff --git a/cooperator_website_recaptcha/__init__.py b/cooperator_website_recaptcha/__init__.py index 91c5580fe..e046e49fb 100644 --- a/cooperator_website_recaptcha/__init__.py +++ b/cooperator_website_recaptcha/__init__.py @@ -1,2 +1 @@ from . import controllers -from . import models diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index f6d465c87..263b93477 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -2,24 +2,18 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - "name": "Cooperators Website Recaptcha", - "summary": """ - Add Google Recaptcha to Subscription Request Form""", - "version": "14.0.1.0.0", + "name": "Cooperators Website reCAPTCHA", + "summary": "Add reCAPTCHA to Subscription Request Form", + "version": "14.0.1.1.0", "category": "Cooperative management", "website": "https://coopiteasy.be", "author": "Coop IT Easy SC", "license": "AGPL-3", - "application": False, "depends": [ "cooperator_website", "portal_recaptcha", ], - "excludes": [], "data": [ - "views/res_company_views.xml", "views/subscription_template.xml", ], - "demo": [], - "qweb": [], } diff --git a/cooperator_website_recaptcha/controllers/main.py b/cooperator_website_recaptcha/controllers/main.py index 5e048b350..723eec892 100644 --- a/cooperator_website_recaptcha/controllers/main.py +++ b/cooperator_website_recaptcha/controllers/main.py @@ -5,39 +5,13 @@ class RecaptchaWebsiteSubscription(WebsiteSubscription): - def validation( # noqa: C901 (method too complex) - self, kwargs, logged, values, post_file - ): - result = super().validation(kwargs, logged, values, post_file) + def _additional_validate(self, kwargs, logged, values, post_file): + result = super()._additional_validate(kwargs, logged, values, post_file) if result is not True: return result - - redirect = "cooperator_website.becomecooperator" - - is_company = kwargs.get("is_company") == "on" - - # TODO: Use a overloaded function with the captcha implementation - if request.env["res.company"].captcha_type == "google": - if ( - "g-recaptcha-response" not in kwargs - or kwargs["g-recaptcha-response"] == "" - ): - values = self.fill_values(values, is_company, logged) - values.update(kwargs) - values["error_msg"] = _( - "the captcha has not been validated, please fill in the captcha" - ) - - return request.render(redirect, values) - elif not request.env["portal.mixin"].is_captcha_valid( - kwargs["g-recaptcha-response"] - ): - values = self.fill_values(values, is_company, logged) - values.update(kwargs) - values["error_msg"] = _( - "the captcha has not been validated, please fill in the captcha" - ) - - return request.render(redirect, values) - - return True + result, error_msg = request.env["portal.mixin"].is_captcha_valid(kwargs) + if not result: + values["error_msg"] = _("Error validating the CAPTCHA: {0}").format( + error_msg + ) + return result diff --git a/cooperator_website_recaptcha/migrations/14.0.1.1.0/pre-migration.py b/cooperator_website_recaptcha/migrations/14.0.1.1.0/pre-migration.py new file mode 100644 index 000000000..d0eb6a169 --- /dev/null +++ b/cooperator_website_recaptcha/migrations/14.0.1.1.0/pre-migration.py @@ -0,0 +1,14 @@ +# Copyright 2022 Coop IT Easy SC +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import SUPERUSER_ID, api + + +def migrate(cr, version): + with api.Environment.manage(): + env = api.Environment(cr, SUPERUSER_ID, {}) + env.cr.execute("select true from res_company where captcha_type = 'google'") + recaptcha_enabled = bool(env.cr.fetchall()) + env["ir.config_parameter"].set_param( + "portal_recaptcha.recaptcha_enabled", recaptcha_enabled + ) diff --git a/cooperator_website_recaptcha/models/__init__.py b/cooperator_website_recaptcha/models/__init__.py deleted file mode 100644 index aff44f335..000000000 --- a/cooperator_website_recaptcha/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import res_company diff --git a/cooperator_website_recaptcha/models/res_company.py b/cooperator_website_recaptcha/models/res_company.py deleted file mode 100644 index 355b2297f..000000000 --- a/cooperator_website_recaptcha/models/res_company.py +++ /dev/null @@ -1,11 +0,0 @@ -from odoo import fields, models - - -class ResCompany(models.Model): - _inherit = "res.company" - captcha_type = fields.Selection( - [("none", "Disabled"), ("google", "Google Recaptcha")], - "Captcha type or disabled", - required=True, - default="google", - ) diff --git a/cooperator_website_recaptcha/views/res_company_views.xml b/cooperator_website_recaptcha/views/res_company_views.xml deleted file mode 100644 index 42b81e88c..000000000 --- a/cooperator_website_recaptcha/views/res_company_views.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - res.company.form.captcha - - res.company - - - - - - - diff --git a/cooperator_website_recaptcha/views/subscription_template.xml b/cooperator_website_recaptcha/views/subscription_template.xml index bb9eac345..c8295d0fc 100644 --- a/cooperator_website_recaptcha/views/subscription_template.xml +++ b/cooperator_website_recaptcha/views/subscription_template.xml @@ -1,23 +1,12 @@ - - - @@ -27,8 +16,7 @@ name="Become Cooperator" > - + - From 8484ce3c2f19e877af865381f68f1a655a50256a Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Fri, 9 Dec 2022 16:04:02 +0100 Subject: [PATCH 13/16] [FIX] fix manifest and update readme fix author and website manifest properties to follow oca's guidelines. --- cooperator_website_recaptcha/README.rst | 32 +- cooperator_website_recaptcha/__manifest__.py | 4 +- .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 423 ++++++++++++++++++ 4 files changed, 449 insertions(+), 11 deletions(-) create mode 100644 cooperator_website_recaptcha/static/description/index.html diff --git a/cooperator_website_recaptcha/README.rst b/cooperator_website_recaptcha/README.rst index 1771a8ea7..662f458ef 100644 --- a/cooperator_website_recaptcha/README.rst +++ b/cooperator_website_recaptcha/README.rst @@ -1,5 +1,5 @@ ============================= -Cooperators Website Recaptcha +Cooperators Website reCAPTCHA ============================= .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -13,11 +13,14 @@ Cooperators Website Recaptcha .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Fvertical--cooperative-lightgray.png?logo=github - :target: https://github.com/coopiteasy/vertical-cooperative/tree/14.0/cooperator_website_recaptcha - :alt: coopiteasy/vertical-cooperative +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcooperator-lightgray.png?logo=github + :target: https://github.com/OCA/cooperator/tree/14.0/cooperator_website_recaptcha + :alt: OCA/cooperator +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/cooperator-14-0/cooperator-14-0-cooperator_website_recaptcha + :alt: Translate me on Weblate -|badge1| |badge2| |badge3| +|badge1| |badge2| |badge3| |badge4| Add Google Recaptcha to Subscription Request Form @@ -29,10 +32,10 @@ Add Google Recaptcha to Subscription Request Form Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -50,10 +53,21 @@ Contributors * `Coop IT Easy SC `_: * Carmen Bianca Bakker + * hugues de keyzer Maintainers ~~~~~~~~~~~ -This module is part of the `coopiteasy/vertical-cooperative `_ project on GitHub. +This module is maintained by the OCA. -You are welcome to contribute. +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/cooperator `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index 263b93477..6f8ab74a4 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -6,8 +6,8 @@ "summary": "Add reCAPTCHA to Subscription Request Form", "version": "14.0.1.1.0", "category": "Cooperative management", - "website": "https://coopiteasy.be", - "author": "Coop IT Easy SC", + "website": "https://github.com/OCA/cooperative", + "author": "Coop IT Easy SC, Odoo Community Association (OCA)", "license": "AGPL-3", "depends": [ "cooperator_website", diff --git a/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst b/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst index d64451edc..26771b9d2 100644 --- a/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst +++ b/cooperator_website_recaptcha/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * `Coop IT Easy SC `_: * Carmen Bianca Bakker + * hugues de keyzer diff --git a/cooperator_website_recaptcha/static/description/index.html b/cooperator_website_recaptcha/static/description/index.html new file mode 100644 index 000000000..cb9dbdd7f --- /dev/null +++ b/cooperator_website_recaptcha/static/description/index.html @@ -0,0 +1,423 @@ + + + + + + +Cooperators Website reCAPTCHA + + + +
+

Cooperators Website reCAPTCHA

+ + +

Beta License: AGPL-3 OCA/cooperator Translate me on Weblate

+

Add Google Recaptcha to Subscription Request Form

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Coop IT Easy SC
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/cooperator project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + From e11af0ae5d2286bb8453f044f47c36492d826ca2 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Mon, 15 Jan 2024 17:47:48 +0100 Subject: [PATCH 14/16] [REF] use website_recaptcha_v2 use website_recaptcha_v2 instead of portal_recaptcha. --- cooperator_website_recaptcha/__manifest__.py | 2 +- cooperator_website_recaptcha/controllers/main.py | 2 +- cooperator_website_recaptcha/views/subscription_template.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index 6f8ab74a4..b1d691e5b 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -11,7 +11,7 @@ "license": "AGPL-3", "depends": [ "cooperator_website", - "portal_recaptcha", + "website_recaptcha_v2", ], "data": [ "views/subscription_template.xml", diff --git a/cooperator_website_recaptcha/controllers/main.py b/cooperator_website_recaptcha/controllers/main.py index 723eec892..f588bae88 100644 --- a/cooperator_website_recaptcha/controllers/main.py +++ b/cooperator_website_recaptcha/controllers/main.py @@ -9,7 +9,7 @@ def _additional_validate(self, kwargs, logged, values, post_file): result = super()._additional_validate(kwargs, logged, values, post_file) if result is not True: return result - result, error_msg = request.env["portal.mixin"].is_captcha_valid(kwargs) + result, error_msg = request.website.is_recaptcha_v2_valid(kwargs) if not result: values["error_msg"] = _("Error validating the CAPTCHA: {0}").format( error_msg diff --git a/cooperator_website_recaptcha/views/subscription_template.xml b/cooperator_website_recaptcha/views/subscription_template.xml index c8295d0fc..9e60054b5 100644 --- a/cooperator_website_recaptcha/views/subscription_template.xml +++ b/cooperator_website_recaptcha/views/subscription_template.xml @@ -6,7 +6,7 @@ name="Become Cooperator" > - + @@ -16,7 +16,7 @@ name="Become Cooperator" > - + From 166a8796d2a032c2c290ed96219addbe74a95916 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Tue, 16 Jan 2024 10:09:12 +0100 Subject: [PATCH 15/16] [MIG] cooperator_website_recaptcha: migration to 15.0 --- cooperator_website_recaptcha/__manifest__.py | 2 +- .../migrations/14.0.1.1.0/pre-migration.py | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 cooperator_website_recaptcha/migrations/14.0.1.1.0/pre-migration.py diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index b1d691e5b..189c8f856 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Cooperators Website reCAPTCHA", "summary": "Add reCAPTCHA to Subscription Request Form", - "version": "14.0.1.1.0", + "version": "15.0.1.0.0", "category": "Cooperative management", "website": "https://github.com/OCA/cooperative", "author": "Coop IT Easy SC, Odoo Community Association (OCA)", diff --git a/cooperator_website_recaptcha/migrations/14.0.1.1.0/pre-migration.py b/cooperator_website_recaptcha/migrations/14.0.1.1.0/pre-migration.py deleted file mode 100644 index d0eb6a169..000000000 --- a/cooperator_website_recaptcha/migrations/14.0.1.1.0/pre-migration.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2022 Coop IT Easy SC -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import SUPERUSER_ID, api - - -def migrate(cr, version): - with api.Environment.manage(): - env = api.Environment(cr, SUPERUSER_ID, {}) - env.cr.execute("select true from res_company where captcha_type = 'google'") - recaptcha_enabled = bool(env.cr.fetchall()) - env["ir.config_parameter"].set_param( - "portal_recaptcha.recaptcha_enabled", recaptcha_enabled - ) From bc8190eb7b78e2b63655bee118955a242e013a43 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Tue, 16 Jan 2024 10:10:46 +0100 Subject: [PATCH 16/16] [MIG] cooperator_website_recaptcha: migration to 16.0 --- cooperator_website_recaptcha/README.rst | 26 +++++++----- cooperator_website_recaptcha/__manifest__.py | 2 +- .../static/description/index.html | 40 ++++++++++--------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/cooperator_website_recaptcha/README.rst b/cooperator_website_recaptcha/README.rst index 662f458ef..766f80b09 100644 --- a/cooperator_website_recaptcha/README.rst +++ b/cooperator_website_recaptcha/README.rst @@ -2,10 +2,13 @@ Cooperators Website reCAPTCHA ============================= -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d7052e563ba6aefe735d7262009fd4f72301aa99b96f9e8945cf9960505c5b12 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -13,14 +16,17 @@ Cooperators Website reCAPTCHA .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcooperator-lightgray.png?logo=github - :target: https://github.com/OCA/cooperator/tree/14.0/cooperator_website_recaptcha - :alt: OCA/cooperator +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcooperative-lightgray.png?logo=github + :target: https://github.com/OCA/cooperative/tree/16.0/cooperator_website_recaptcha + :alt: OCA/cooperative .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/cooperator-14-0/cooperator-14-0-cooperator_website_recaptcha + :target: https://translation.odoo-community.org/projects/cooperative-16-0/cooperative-16-0-cooperator_website_recaptcha :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/cooperative&target_branch=16.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| +|badge1| |badge2| |badge3| |badge4| |badge5| Add Google Recaptcha to Subscription Request Form @@ -32,10 +38,10 @@ Add Google Recaptcha to Subscription Request Form Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -68,6 +74,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/cooperator `_ project on GitHub. +This module is part of the `OCA/cooperative `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/cooperator_website_recaptcha/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index 189c8f856..baccc1b95 100644 --- a/cooperator_website_recaptcha/__manifest__.py +++ b/cooperator_website_recaptcha/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Cooperators Website reCAPTCHA", "summary": "Add reCAPTCHA to Subscription Request Form", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "category": "Cooperative management", "website": "https://github.com/OCA/cooperative", "author": "Coop IT Easy SC, Odoo Community Association (OCA)", diff --git a/cooperator_website_recaptcha/static/description/index.html b/cooperator_website_recaptcha/static/description/index.html index cb9dbdd7f..f20b06381 100644 --- a/cooperator_website_recaptcha/static/description/index.html +++ b/cooperator_website_recaptcha/static/description/index.html @@ -1,20 +1,20 @@ - + - + Cooperators Website reCAPTCHA