From 81bb492bb75d081dbb9ac0440eea778e53b90524 Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Fri, 15 Apr 2022 15:34:48 +0200 Subject: [PATCH 01/12] [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 451ed22f44c079ed35956c93a75708d6a623f14b Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Mon, 23 May 2022 08:14:10 +0000 Subject: [PATCH 02/12] [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 ec8032ded424dad587ccfd6ccfb0c1c1286db15f Mon Sep 17 00:00:00 2001 From: oca-ci Date: Wed, 1 Jun 2022 10:10:23 +0200 Subject: [PATCH 03/12] [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 3f8cffa8b419e666c717fa2cd230983ae5fa4649 Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Tue, 10 May 2022 13:38:08 +0200 Subject: [PATCH 04/12] [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 b419cc6a9cfc565cf266456ea9ee6b3e4cc80279 Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Tue, 10 May 2022 16:26:37 +0200 Subject: [PATCH 05/12] [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 35a7d5b98bc4e025cc2073b0535f820840f763d2 Mon Sep 17 00:00:00 2001 From: Github GRAP Bot Date: Thu, 23 Jun 2022 14:51:47 +0000 Subject: [PATCH 06/12] [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 212d922ad9cdc1ae2d834aba9bc39ba76e9f0080 Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Wed, 29 Jun 2022 11:20:24 +0200 Subject: [PATCH 07/12] =?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 7eccc2b1f921e4242486fcb821c3f98528512e39 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Mon, 22 Aug 2022 10:18:09 +0200 Subject: [PATCH 08/12] [IMP] update readme --- .../static/description/index.html | 417 ++++++++++++++++++ 1 file changed, 417 insertions(+) create mode 100644 cooperator_website_recaptcha/static/description/index.html diff --git a/cooperator_website_recaptcha/static/description/index.html b/cooperator_website_recaptcha/static/description/index.html new file mode 100644 index 000000000..23bfa57ea --- /dev/null +++ b/cooperator_website_recaptcha/static/description/index.html @@ -0,0 +1,417 @@ + + + + + + +Cooperators Website Recaptcha + + + +
+

Cooperators Website Recaptcha

+ + +

Beta License: AGPL-3 coopiteasy/vertical-cooperative

+

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 part of the coopiteasy/vertical-cooperative project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + From f0bd6785cd551cf431b817da7280726c5a84451d Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Fri, 16 Sep 2022 16:02:28 +0200 Subject: [PATCH 09/12] [IMP] backport changes from migration to 14.0 co-authored-by: Carmen Bianca Bakker --- cooperator_website_recaptcha/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 6a2d9a8998dcd77425d5e21c5918b0d77252bc2f Mon Sep 17 00:00:00 2001 From: Github GRAP Bot Date: Mon, 3 Oct 2022 09:23:00 +0000 Subject: [PATCH 10/12] cooperator_website_recaptcha 12.0.1.0.1 --- 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 6fa08bbbd..80614455c 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": "12.0.1.0.1", "category": "Cooperative management", "website": "https://coopiteasy.be", "author": "Coop IT Easy SC", From a39eaadccd2a4ee9a73d4818dd68dfae7fad597f Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Fri, 9 Dec 2022 14:06:49 +0100 Subject: [PATCH 11/12] [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/__manifest__.py | 12 ++---- .../controllers/main.py | 42 ++++--------------- .../migrations/12.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 +------ 7 files changed, 27 insertions(+), 82 deletions(-) create mode 100644 cooperator_website_recaptcha/migrations/12.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/__manifest__.py b/cooperator_website_recaptcha/__manifest__.py index 80614455c..4ea88229c 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": "12.0.1.0.1", + "name": "Cooperators Website reCAPTCHA", + "summary": "Add reCAPTCHA to Subscription Request Form", + "version": "12.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/12.0.1.1.0/pre-migration.py b/cooperator_website_recaptcha/migrations/12.0.1.1.0/pre-migration.py new file mode 100644 index 000000000..d0eb6a169 --- /dev/null +++ b/cooperator_website_recaptcha/migrations/12.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 bc505e953dd01f1fc94ec0d4cb55e5e8e5f79b7b Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Fri, 9 Dec 2022 16:04:02 +0100 Subject: [PATCH 12/12] [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 | 20 ++++++++---- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/cooperator_website_recaptcha/README.rst b/cooperator_website_recaptcha/README.rst index a0f54e705..f18933d27 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/12.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/12.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-12-0/cooperator-12-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 4ea88229c..05fad11d9 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": "12.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 index 23bfa57ea..9a8560d61 100644 --- a/cooperator_website_recaptcha/static/description/index.html +++ b/cooperator_website_recaptcha/static/description/index.html @@ -4,7 +4,7 @@ -Cooperators Website Recaptcha +Cooperators Website reCAPTCHA