Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website_form_recaptcha/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Look at `website_crm_recaptcha` module for example implementation

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/9.0
:target: https://runbot.odoo-community.org/runbot/186/10.0


Known Issues / Road Map
Expand Down
2 changes: 1 addition & 1 deletion website_form_recaptcha/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
Expand Down
8 changes: 4 additions & 4 deletions website_form_recaptcha/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-
# © 2016-TODAY LasLabs Inc.
# Copyright 2016-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Website Form - ReCaptcha",
"summary": 'Provides a ReCaptcha field for Website Forms',
"version": "9.0.1.0.0",
"version": "10.0.1.0.0",
"category": "Website",
"website": "https://laslabs.com/",
"author": "LasLabs, Odoo Community Association",
"author": "LasLabs, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
'installable': False,
'installable': True,
"depends": [
"website_form",
],
Expand Down
2 changes: 1 addition & 1 deletion website_form_recaptcha/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016-TODAY LasLabs Inc.
# Copyright 2016-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import main
8 changes: 4 additions & 4 deletions website_form_recaptcha/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016-TODAY LasLabs Inc.
# Copyright 2016-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import http
Expand Down Expand Up @@ -27,9 +27,9 @@ def recaptcha_public(self):
),
})

def extract_data(self, model, **kwargs):
def extract_data(self, model, values):
""" Inject ReCaptcha validation into pre-existing data extraction """
res = super(WebsiteForm, self).extract_data(model, **kwargs)
res = super(WebsiteForm, self).extract_data(model, values)
if model.website_form_recaptcha:
captcha_obj = request.env['website.form.recaptcha']
ip_addr = request.httprequest.environ.get('HTTP_X_FORWARDED_FOR')
Expand All @@ -39,7 +39,7 @@ def extract_data(self, model, **kwargs):
ip_addr = request.httprequest.remote_addr
try:
captcha_obj.action_validate(
kwargs.get(captcha_obj.RESPONSE_ATTR), ip_addr
values.get(captcha_obj.RESPONSE_ATTR), ip_addr
)
except ValidationError:
raise ValidationError([captcha_obj.RESPONSE_ATTR])
Expand Down
4 changes: 2 additions & 2 deletions website_form_recaptcha/data/ir_config_parameter_data.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
Copyright (C) 2016-TODAY LasLabs [https://laslabs.com]
@license AGPL-3
Copyright 2016-2017 LasLabs Inc.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->


Expand Down
2 changes: 1 addition & 1 deletion website_form_recaptcha/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import ir_model
Expand Down
2 changes: 1 addition & 1 deletion website_form_recaptcha/models/ir_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields
Expand Down
2 changes: 1 addition & 1 deletion website_form_recaptcha/models/website_form_recaptcha.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, api
Expand Down
57 changes: 28 additions & 29 deletions website_form_recaptcha/static/src/js/field_recaptcha.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
/* © 2016-TODAY LasLabs Inc.
/* Copyright 2016-2017 LasLabs Inc.
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*/

odoo.define('website_form_recaptcha.recaptcha', function(require){
"use strict";

var snippet_animation = require('web_editor.snippets.animation');
var $ = require("$");

snippet_animation.registry.form_builder_send = snippet_animation.registry.form_builder_send.extend({

start: function() {
var self = this;
this._super();
this.$captchas = self.$('.o_website_form_recaptcha');
$.ajax({
url: '/website/recaptcha/',
method: 'GET',
success: function(data){
data = JSON.parse(data);
self.$captchas.append($(
'<div class="g-recaptcha" data-sitekey="' + data.site_key + '"></div>'
));
if (self.$captchas.length) {
$.getScript('https://www.google.com/recaptcha/api.js');
}
},
});
}

});

"use strict";

var snippet_animation = require('web_editor.snippets.animation');

snippet_animation.registry.form_builder_send = snippet_animation.registry.form_builder_send.extend({

start: function() {
var self = this;
this._super();
this.$captchas = self.$('.o_website_form_recaptcha');
$.ajax({
url: '/website/recaptcha/',
method: 'GET',
success: function(data){
data = JSON.parse(data);
self.$captchas.append($(
'<div class="g-recaptcha" data-sitekey="' + data.site_key + '"></div>'
));
if (self.$captchas.length) {
$.getScript('https://www.google.com/recaptcha/api.js');
}
},
});
}

});

});
2 changes: 2 additions & 0 deletions website_form_recaptcha/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import test_captcha
2 changes: 1 addition & 1 deletion website_form_recaptcha/tests/test_captcha.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015-TODAY LasLabs Inc.
# Copyright 2015-2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests.common import TransactionCase
Expand Down
4 changes: 2 additions & 2 deletions website_form_recaptcha/views/assets.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
© 2016-TODAY LasLabs Inc.
@license AGPL-3 or later (http://www.gnu.org/licenses/agpl.html).
Copyright 2016-2017 LasLabs Inc.
License AGPL-3 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>
Expand Down