diff --git a/easy_my_coop_website/__init__.py b/easy_my_coop_website/__init__.py
index e046e49fb..91c5580fe 100644
--- a/easy_my_coop_website/__init__.py
+++ b/easy_my_coop_website/__init__.py
@@ -1 +1,2 @@
from . import controllers
+from . import models
diff --git a/easy_my_coop_website/__manifest__.py b/easy_my_coop_website/__manifest__.py
index db2f37628..c665b87f8 100644
--- a/easy_my_coop_website/__manifest__.py
+++ b/easy_my_coop_website/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Easy My Coop Website",
- "version": "12.0.1.0.0",
+ "version": "12.0.1.0.3",
"depends": ["easy_my_coop", "website", "website_recaptcha_reloaded"],
"author": "Coop IT Easy SCRLfs",
"category": "Cooperative management",
@@ -17,6 +17,7 @@
""",
"data": [
"views/subscription_template.xml",
+ "views/res_company_view.xml",
"data/website_cooperator_data.xml",
],
"installable": True,
diff --git a/easy_my_coop_website/controllers/main.py b/easy_my_coop_website/controllers/main.py
index ce8ff2e9d..20e07c4ee 100644
--- a/easy_my_coop_website/controllers/main.py
+++ b/easy_my_coop_website/controllers/main.py
@@ -255,30 +255,31 @@ def validation(self, kwargs, logged, values, post_file):
is_company = True
redirect = "easy_my_coop_website.becomecompanycooperator"
email = kwargs.get("company_email")
+ # TODO: Use a overloaded function with the captcha implementation
+ if request.website.company_id.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"
+ )
- 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.website.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)
+ elif not request.website.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 request.render(redirect, values)
# Check that required field from model subscription_request exists
required_fields = sub_req_obj.sudo().get_required_field()
diff --git a/easy_my_coop_website/models/__init__.py b/easy_my_coop_website/models/__init__.py
new file mode 100644
index 000000000..52e101612
--- /dev/null
+++ b/easy_my_coop_website/models/__init__.py
@@ -0,0 +1 @@
+from . import company
diff --git a/easy_my_coop_website/models/company.py b/easy_my_coop_website/models/company.py
new file mode 100644
index 000000000..0474e0595
--- /dev/null
+++ b/easy_my_coop_website/models/company.py
@@ -0,0 +1,9 @@
+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/easy_my_coop_website/views/res_company_view.xml b/easy_my_coop_website/views/res_company_view.xml
new file mode 100644
index 000000000..8dbce1b81
--- /dev/null
+++ b/easy_my_coop_website/views/res_company_view.xml
@@ -0,0 +1,14 @@
+
+
+
@@ -971,7 +973,9 @@
|