Browse Source

Using website.recaptcha_key_site as active flag

pull/107/head
César López Ramírez 4 years ago
parent
commit
bf4662e9e3
  1. 1
      easy_my_coop_website/__init__.py
  2. 2
      easy_my_coop_website/__manifest__.py
  3. 7
      easy_my_coop_website/controllers/main.py
  4. 6
      easy_my_coop_website/data/emc_website_recaptcha.xml
  5. 1
      easy_my_coop_website/models/__init__.py
  6. 25
      easy_my_coop_website/models/res_config_settings.py
  7. 28
      easy_my_coop_website/views/res_config_settings.xml
  8. 3
      easy_my_coop_website/views/subscription_template.xml

1
easy_my_coop_website/__init__.py

@ -1,2 +1 @@
from . import controllers from . import controllers
from . import models

2
easy_my_coop_website/__manifest__.py

@ -17,9 +17,7 @@
""", """,
"data": [ "data": [
"views/subscription_template.xml", "views/subscription_template.xml",
"views/res_config_settings.xml",
"data/website_cooperator_data.xml", "data/website_cooperator_data.xml",
"data/emc_website_recaptcha.xml"
], ],
"installable": True, "installable": True,
"application": True, "application": True,

7
easy_my_coop_website/controllers/main.py

@ -173,10 +173,6 @@ class WebsiteSubscription(http.Controller):
sub_req_obj = request.env["subscription.request"] sub_req_obj = request.env["subscription.request"]
company = request.website.company_id company = request.website.company_id
products = self.get_products_share(is_company) products = self.get_products_share(is_company)
icp_obj = request.env["ir.config_parameter"].sudo()
values["recaptcha_enabled"] = icp_obj.get_param(
"emc_website.captcha_enabled", default="True"
)
if load_from_user: if load_from_user:
values = self.get_values_from_user(values, is_company) values = self.get_values_from_user(values, is_company)
if is_company: if is_company:
@ -248,7 +244,6 @@ class WebsiteSubscription(http.Controller):
def validation(self, kwargs, logged, values, post_file): def validation(self, kwargs, logged, values, post_file):
user_obj = request.env["res.users"] user_obj = request.env["res.users"]
sub_req_obj = request.env["subscription.request"] sub_req_obj = request.env["subscription.request"]
icp_obj = request.env["ir.config_parameter"].sudo()
redirect = "easy_my_coop_website.becomecooperator" redirect = "easy_my_coop_website.becomecooperator"
email = kwargs.get("email") email = kwargs.get("email")
@ -259,7 +254,7 @@ class WebsiteSubscription(http.Controller):
redirect = "easy_my_coop_website.becomecompanycooperator" redirect = "easy_my_coop_website.becomecompanycooperator"
email = kwargs.get("company_email") email = kwargs.get("company_email")
if icp_obj.get_param('emc_website.captcha_enabled')=="True":
if request.website.recaptcha_key_site:
if ( if (
"g-recaptcha-response" not in kwargs "g-recaptcha-response" not in kwargs
or kwargs["g-recaptcha-response"] == "" or kwargs["g-recaptcha-response"] == ""

6
easy_my_coop_website/data/emc_website_recaptcha.xml

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<function model="ir.config_parameter" name="set_param" eval="('emc_website.captcha_enabled', True)"/>
</data>
</odoo>

1
easy_my_coop_website/models/__init__.py

@ -1 +0,0 @@
from . import res_config_settings

25
easy_my_coop_website/models/res_config_settings.py

@ -1,25 +0,0 @@
from odoo import api,fields,models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
captcha_enabled = fields.Boolean("Google Recaptcha Module active?", default=True)
@api.multi
def set_values(self):
super(ResConfigSettings, self).set_values()
ICPSudo = self.env['ir.config_parameter'].sudo()
ICPSudo.set_param(
'emc_website.captcha_enabled',
'True' if self.captcha_enabled else 'False'
)
@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
ICPSudo = self.env['ir.config_parameter'].sudo()
res.update({
'captcha_enabled': (True if ICPSudo.get_param(
'emc_website.captcha_enabled', default=True) == 'True' else False)
})
return res

28
easy_my_coop_website/views/res_config_settings.xml

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.web_google_maps</field>
<field name="priority" eval="200"/>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='integration']" position="after">
<div name="emc_website_recaptcha">
<h2>Easy My Coop Website</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="captcha_enabled"/>
</div>
<div class="o_setting_right_pane">
<label for="captcha_enabled"/>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</data>
</odoo>

3
easy_my_coop_website/views/subscription_template.xml

@ -473,12 +473,11 @@
<table style="margin-left:195px"> <table style="margin-left:195px">
<tr> <tr>
<td width="80%"> <td width="80%">
<t t-if="recaptcha_enabled == 'True'">
<div class="g-recaptcha" <div class="g-recaptcha"
t-if="website.recaptcha_key_site"
t-att-data-sitekey="website.recaptcha_key_site" t-att-data-sitekey="website.recaptcha_key_site"
data-theme="green"/> data-theme="green"/>
<br/> <br/>
</t>
</td> </td>
<td> <td>
<div class="form-group"> <div class="form-group">

Loading…
Cancel
Save