Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from coopiteasy/12.0-komunigi-cooperator_webs…
…ite_recaptcha [REF] Split cooperator_website into cooperator_website_recaptcha
- Loading branch information
Showing
18 changed files
with
119 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Removed reCAPTCHA logic out of this module. Install | ||
``cooperator_website_recaptcha`` to regain the functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import res_company |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* `Coop IT Easy SCRLfs <https://coopiteasy.be>`_: | ||
|
||
* Carmen Bianca Bakker |
Empty file.
2 changes: 1 addition & 1 deletion
2
...erator_website/views/res_company_view.xml → ...ite_recaptcha/views/res_company_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
cooperator_website_recaptcha/views/subscription_template.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<template id="captcha_template" name="captcha_template"> | ||
<div | ||
class="g-recaptcha text-xs-center" | ||
t-if="res_company.captcha_type == 'google'" | ||
t-att-data-sitekey="request.env['ir.config_parameter'].sudo().get_param('portal_recaptcha.recaptcha_key_site')" | ||
data-theme="green" | ||
name="recaptcha_key_site" | ||
/> | ||
</template> | ||
|
||
<template | ||
id="becomecooperator" | ||
inherit_id="cooperator_website.becomecooperator" | ||
name="Become Cooperator" | ||
> | ||
<xpath expr="//t[@t-call='cooperator_website.rules_template']" position="after"> | ||
<t t-call="cooperator_website.captcha_template" /> | ||
</xpath> | ||
</template> | ||
|
||
<template | ||
id="becomecompanycooperator" | ||
inherit_id="cooperator_website.becomecompanycooperator" | ||
name="Become Cooperator" | ||
> | ||
<xpath expr="//t[@t-call='cooperator_website.rules_template']" position="after"> | ||
<t t-call="cooperator_website.captcha_template" /> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
1 change: 1 addition & 0 deletions
1
setup/cooperator_website_recaptcha/odoo/addons/cooperator_website_recaptcha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../cooperator_website_recaptcha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |