openerp-community team mailing list archive
-
openerp-community team
-
Mailing list archive
-
Message #05234
[Merge] lp:~ajite/openobject-addons/elico-trunk-add-0001 into lp:~openerp-community/openobject-addons/elico-trunk
Augustin Cisterne-Kaas - www.elico-corp.com has proposed merging lp:~ajite/openobject-addons/elico-trunk-add-0001 into lp:~openerp-community/openobject-addons/elico-trunk.
Requested reviews:
OpenERP Community (openerp-community)
For more details, see:
https://code.launchpad.net/~ajite/openobject-addons/elico-trunk-add-0001/+merge/210569
[ADD] Website reCAPTCHA and Contact Form reCAPTCHA
--
https://code.launchpad.net/~ajite/openobject-addons/elico-trunk-add-0001/+merge/210569
Your team OpenERP Community is requested to review the proposed merge of lp:~ajite/openobject-addons/elico-trunk-add-0001 into lp:~openerp-community/openobject-addons/elico-trunk.
=== added directory 'website_crm_recaptcha'
=== added file 'website_crm_recaptcha/__init__.py'
--- website_crm_recaptcha/__init__.py 1970-01-01 00:00:00 +0000
+++ website_crm_recaptcha/__init__.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import controllers
=== added file 'website_crm_recaptcha/__openerp__.py'
--- website_crm_recaptcha/__openerp__.py 1970-01-01 00:00:00 +0000
+++ website_crm_recaptcha/__openerp__.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{'name': 'Contact Form reCAPTCHA',
+ 'version': '1.0',
+ 'category': 'Website',
+ 'depends': ['website_recaptcha', 'website_crm'],
+ 'author': 'Elico Corp',
+ 'license': 'AGPL-3',
+ 'website': 'https://www.elico-corp.com',
+ 'description': """
+OpenERP Contact Form reCAPTCHA
+==============================
+You can configure your Google reCAPTCHA private and public keys
+in "Settings" -> "Website Settings"
+""",
+ 'data': [
+ 'views/website_crm.xml'
+ ],
+ 'installable': True,
+ 'auto_install': False}
=== added directory 'website_crm_recaptcha/controllers'
=== added file 'website_crm_recaptcha/controllers/__init__.py'
--- website_crm_recaptcha/controllers/__init__.py 1970-01-01 00:00:00 +0000
+++ website_crm_recaptcha/controllers/__init__.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import main
=== added file 'website_crm_recaptcha/controllers/main.py'
--- website_crm_recaptcha/controllers/main.py 1970-01-01 00:00:00 +0000
+++ website_crm_recaptcha/controllers/main.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from openerp.addons.web import http
+from openerp.addons.web.http import request
+import openerp.addons.website_crm.controllers.main as main
+
+
+class contactus(main.contactus):
+
+ @http.route(['/crm/contactus'], type='http', auth="public",
+ website=True, multilang=True)
+ def contactus(self, *args, **kw):
+ challenge = kw.pop('recaptcha_challenge_field', None)
+ response = kw.pop('recaptcha_response_field', None)
+ if not kw or not challenge or not response:
+ pass
+ elif request.website.is_captcha_valid(challenge, response):
+ return super(contactus, self).contactus(*args, **kw)
+ else:
+ kw['error'] = set(['recaptcha_response_field'])
+ return request.website.render("website.contactus", kw)
=== added directory 'website_crm_recaptcha/static'
=== added directory 'website_crm_recaptcha/static/description'
=== added file 'website_crm_recaptcha/static/description/example.png'
Binary files website_crm_recaptcha/static/description/example.png 1970-01-01 00:00:00 +0000 and website_crm_recaptcha/static/description/example.png 2014-03-12 10:12:53 +0000 differ
=== added file 'website_crm_recaptcha/static/description/icon.png'
Binary files website_crm_recaptcha/static/description/icon.png 1970-01-01 00:00:00 +0000 and website_crm_recaptcha/static/description/icon.png 2014-03-12 10:12:53 +0000 differ
=== added file 'website_crm_recaptcha/static/description/index.html'
--- website_crm_recaptcha/static/description/index.html 1970-01-01 00:00:00 +0000
+++ website_crm_recaptcha/static/description/index.html 2014-03-12 10:12:53 +0000
@@ -0,0 +1,13 @@
+<section class="oe_container">
+ <div class="oe_row">
+ <h2 class="oe_slogan">Contact Form reCAPTCHA</h2>
+ <h4 class="oe_slogan"><a href="http://www.elico-corp.com">By Elico Corp</a></h4>
+ <p>
+ This modules allows you to integrate Google reCAPTCHA to your Website forms. You can configure your Google reCAPTCHA private and public keys in "Settings" -> "Website Settings"
+ </p>
+
+ <div class="oe_row_img oe_centered oe_mt32">
+ <img class="oe_picture oe_screenshot" src="example.png" />
+ </div>
+ </div>
+</section>
\ No newline at end of file
=== added directory 'website_crm_recaptcha/views'
=== added file 'website_crm_recaptcha/views/website_crm.xml'
--- website_crm_recaptcha/views/website_crm.xml 1970-01-01 00:00:00 +0000
+++ website_crm_recaptcha/views/website_crm.xml 2014-03-12 10:12:53 +0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+ <data>
+ <template id="contactus_form_recaptcha" name="Google reCAPTCHA" inherit_id="website_crm.contactus_form" inherit_option_id="website_crm.contactus_form">
+ <xpath expr="//form" position="before">
+ <script type="text/javascript">
+ var RecaptchaOptions = {
+ theme : '<t t-esc="website.recaptcha_theme" />'
+ };
+
+ </script>
+ </xpath>
+ <xpath expr="//button/../.." position="before">
+ <t t-call="website_recaptcha.captcha"/>
+ </xpath>
+ </template>
+ </data>
+</openerp>
\ No newline at end of file
=== added directory 'website_recaptcha'
=== added file 'website_recaptcha/__init__.py'
--- website_recaptcha/__init__.py 1970-01-01 00:00:00 +0000
+++ website_recaptcha/__init__.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import website
+import models
\ No newline at end of file
=== added file 'website_recaptcha/__openerp__.py'
--- website_recaptcha/__openerp__.py 1970-01-01 00:00:00 +0000
+++ website_recaptcha/__openerp__.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{'name': 'Website reCAPTCHA',
+ 'version': '1.0',
+ 'category': 'Website',
+ 'depends': ['website'],
+ 'author': 'Elico Corp',
+ 'license': 'AGPL-3',
+ 'website': 'https://www.elico-corp.com',
+ 'description': """
+OpenERP reCAPTCHA
+=================
+This modules allows you to integrate Google reCAPTCHA to your website forms.
+You can configure your Google reCAPTCHA private and public keys
+in "Settings" -> "Website Settings"
+
+You will need to install the "Website CRM reCAPTCHA module"
+to use it in your "contact us" page
+""",
+ 'data': [
+ 'views/website_templates.xml',
+ 'views/website_view.xml',
+ 'views/res_config.xml',
+ ],
+ 'installable': True,
+ 'auto_install': False}
=== added directory 'website_recaptcha/models'
=== added file 'website_recaptcha/models/__init__.py'
--- website_recaptcha/models/__init__.py 1970-01-01 00:00:00 +0000
+++ website_recaptcha/models/__init__.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import res_config
=== added file 'website_recaptcha/models/res_config.py'
--- website_recaptcha/models/res_config.py 1970-01-01 00:00:00 +0000
+++ website_recaptcha/models/res_config.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import fields, osv
+
+
+class website_config_settings(osv.osv_memory):
+ _inherit = 'website.config.settings'
+
+ # makes it overridable for custom theme
+ def _select_themes(self, cr, uid, context=None):
+ """ Available concepts
+
+ Can be inherited to add custom versions.
+ """
+ return [('red', 'Red'),
+ ('white', 'White'),
+ ('blackglass', 'Blackglass'),
+ ('clean', 'Clean')]
+
+ _columns = {
+ 'recaptcha_public_key': fields.related(
+ 'website_id', 'recaptcha_public_key', type="char",
+ string='reCAPTCHA Public Key'),
+ 'recaptcha_private_key': fields.related(
+ 'website_id', 'recaptcha_private_key', type="char",
+ string='reCAPTCHA Private Key'),
+ 'recaptcha_theme': fields.related(
+ 'website_id', 'recaptcha_theme', type="selection",
+ selection=_select_themes, string='reCAPTCHA theme', required=True)
+ }
+
+ _defaults = {
+ 'recaptcha_theme': 'red'
+ }
=== added directory 'website_recaptcha/static'
=== added directory 'website_recaptcha/static/description'
=== added file 'website_recaptcha/static/description/example.png'
Binary files website_recaptcha/static/description/example.png 1970-01-01 00:00:00 +0000 and website_recaptcha/static/description/example.png 2014-03-12 10:12:53 +0000 differ
=== added file 'website_recaptcha/static/description/icon.png'
Binary files website_recaptcha/static/description/icon.png 1970-01-01 00:00:00 +0000 and website_recaptcha/static/description/icon.png 2014-03-12 10:12:53 +0000 differ
=== added file 'website_recaptcha/static/description/index.html'
--- website_recaptcha/static/description/index.html 1970-01-01 00:00:00 +0000
+++ website_recaptcha/static/description/index.html 2014-03-12 10:12:53 +0000
@@ -0,0 +1,16 @@
+<section class="oe_container">
+ <div class="oe_row">
+ <h2 class="oe_slogan">Website reCAPTCHA</h2>
+ <h4 class="oe_slogan"><a href="http://www.elico-corp.com">By Elico Corp</a></h4>
+ <p>
+ This modules allows you to integrate Google reCAPTCHA to your Website forms. You can configure your Google reCAPTCHA private and public keys in "Settings" -> "Website Settings"
+ </p>
+ <p>
+ You will need to install the "Website CRM reCAPTCHA module" to use it in your "contact us" page
+ </p>
+
+ <div class="oe_row_img oe_centered oe_mt32">
+ <img class="oe_picture oe_screenshot" src="example.png" />
+ </div>
+ </div>
+</section>
\ No newline at end of file
=== added directory 'website_recaptcha/views'
=== added file 'website_recaptcha/views/res_config.xml'
--- website_recaptcha/views/res_config.xml 1970-01-01 00:00:00 +0000
+++ website_recaptcha/views/res_config.xml 2014-03-12 10:12:53 +0000
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="view_website_config_settings" model="ir.ui.view">
+ <field name="name">Website settings</field>
+ <field name="model">website.config.settings</field>
+ <field name="inherit_id" ref="website.view_website_config_settings" />
+ <field name="arch" type="xml">
+ <group string="Social Media" position="after">
+ <group string="Google reCAPTCHA">
+ <label for="recaptcha_public_key"/>
+ <div name="recaptcha_public_key">
+ <div class="oe_inline">
+ <field name="recaptcha_public_key" placeholder="Your reCAPTCHA public key"/>
+ </div>
+ </div>
+ <label for="recaptcha_private_key"/>
+ <div name="recaptcha_private_key">
+ <div class="oe_inline">
+ <field name="recaptcha_private_key" placeholder="Your reCAPTCHA private key"/>
+ </div>
+ </div>
+ <label for="recaptcha_theme"/>
+ <div name="recaptcha_theme">
+ <div class="oe_inline">
+ <field name="recaptcha_theme" />
+ </div>
+ </div>
+ </group>
+ </group>
+ </field>
+ </record>
+ </data>
+</openerp>
=== added file 'website_recaptcha/views/website_templates.xml'
--- website_recaptcha/views/website_templates.xml 1970-01-01 00:00:00 +0000
+++ website_recaptcha/views/website_templates.xml 2014-03-12 10:12:53 +0000
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+ <data>
+ <template id="website_recaptcha.captcha" name="reCAPTCHA">
+ <div t-attf-class="form-group #{error and 'recaptcha_response_field' in error and 'has-error' or ''}">
+ <label class="col-md-3 col-sm-4 control-label" for="description">Captcha</label>
+ <div class="col-md-7 col-sm-8">
+ <script type="text/javascript"
+ t-att-src="'http://www.google.com/recaptcha/api/challenge?k=%s' % website.recaptcha_public_key"></script>
+ <noscript>
+ <iframe t-att-src="'http://www.google.com/recaptcha/api/challenge?k=%s' % website.recaptcha_public_key"
+ height="300" width="500" frameborder="0"></iframe>
+ <br />
+ <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
+ <input type="hidden" name="recaptcha_response_field"
+ value="manual_challenge" />
+ </noscript>
+ </div>
+ </div>
+ </template>
+ </data>
+</openerp>
\ No newline at end of file
=== added file 'website_recaptcha/views/website_view.xml'
--- website_recaptcha/views/website_view.xml 1970-01-01 00:00:00 +0000
+++ website_recaptcha/views/website_view.xml 2014-03-12 10:12:53 +0000
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record id="view_website_form" model="ir.ui.view">
+ <field name="name">website.form</field>
+ <field name="model">website</field>
+ <field name="inherit_id" ref="website.view_website_form" />
+ <field name="arch" type="xml">
+ <div name="social_media" position="after">
+ <div name="goole_recaptcha">
+ <separator string="Google reCAPTCHA"/>
+ <group name="social_media">
+ <field name="recaptcha_public_key" placeholder="Your reCAPTCHA public key"/>
+ <field name="recaptcha_private_key" placeholder="Your reCAPTCHA private key"/>
+ <field name="recaptcha_theme" />
+ </group>
+ </div>
+ </div>
+ </field>
+ </record>
+ </data>
+</openerp>
=== added file 'website_recaptcha/website.py'
--- website_recaptcha/website.py 1970-01-01 00:00:00 +0000
+++ website_recaptcha/website.py 2014-03-12 10:12:53 +0000
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@xxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from openerp.osv import orm, fields
+from recaptcha.client import captcha
+
+
+class website(orm.Model):
+ _inherit = 'website'
+
+ # makes it overridable for custom theme
+ def _select_themes(self, cr, uid, context=None):
+ """ Available concepts
+
+ Can be inherited to add custom versions.
+ """
+ return [('red', 'Red'),
+ ('white', 'White'),
+ ('blackglass', 'Blackglass'),
+ ('clean', 'Clean')]
+
+ _columns = {
+ 'recaptcha_public_key': fields.char('reCAPTCHA Public Key'),
+ 'recaptcha_private_key': fields.char('reCAPTCHA Private Key'),
+ 'recaptcha_theme': fields.selection(
+ _select_themes, string='reCAPTCHA theme', required=True)
+ }
+
+ _defaults = {
+ 'recaptcha_theme': 'red'
+ }
+
+ def is_captcha_valid(self, cr, uid, ids, challenge, response,
+ context=None):
+ assert len(ids) == 1
+
+ website = self.browse(cr, uid, ids[0])
+ res = captcha.submit(
+ challenge,
+ response,
+ website.recaptcha_private_key,
+ website.name
+ )
+ return res.is_valid
Follow ups