diff --git a/website_recaptcha_reloaded/__init__.py b/website_recaptcha_reloaded/__init__.py new file mode 100644 index 0000000..38706fe --- /dev/null +++ b/website_recaptcha_reloaded/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Tech-Receptives Solutions Pvt. Ltd. +# Copyright (C)2004-TODAY Tech Receptives() +# +# 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 . +# +############################################################################## +import website +import models \ No newline at end of file diff --git a/website_recaptcha_reloaded/__openerp__.py b/website_recaptcha_reloaded/__openerp__.py new file mode 100644 index 0000000..ae12f42 --- /dev/null +++ b/website_recaptcha_reloaded/__openerp__.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Tech-Receptives Solutions Pvt. Ltd. +# Copyright (C)2004-TODAY Tech Receptives() +# +# 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 . +# +############################################################################## +{'name': 'Website reCAPTCHA Reloaded', + 'version': '1.0', + 'category': 'Website', + 'depends': ['website'], + 'author': 'Tech Receptives', + 'license': 'AGPL-3', + 'website': 'https://www.techreceptives.com', + 'description': """ +Odoo Website reCAPTCHA Reloaded +================================ +This modules allows you to integrate Google reCAPTCHA v2.0 to your website forms. +You can configure your Google reCAPTCHA site and public keys +in "Settings" -> "Website Settings" + +You will need to install various website__recaptcha modules +to use it in your various pages. +""", + 'data': [ + 'views/website_view.xml', + 'views/res_config.xml', + ], + 'installable': True, + 'auto_install': False +} diff --git a/website_recaptcha_reloaded/models/__init__.py b/website_recaptcha_reloaded/models/__init__.py new file mode 100644 index 0000000..a199d14 --- /dev/null +++ b/website_recaptcha_reloaded/models/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Tech-Receptives Solutions Pvt. Ltd. +# Copyright (C)2004-TODAY Tech Receptives() +# +# 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 . +# +############################################################################## +import res_config diff --git a/website_recaptcha_reloaded/models/res_config.py b/website_recaptcha_reloaded/models/res_config.py new file mode 100644 index 0000000..71e6833 --- /dev/null +++ b/website_recaptcha_reloaded/models/res_config.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Tech-Receptives Solutions Pvt. Ltd. +# Copyright (C)2004-TODAY Tech Receptives() +# +# 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 . +# +############################################################################## + +from openerp.osv import fields, osv + + +class website_config_settings(osv.osv_memory): + _inherit = 'website.config.settings' + + _columns = { + 'recaptcha_site_key': fields.related( + 'website_id', 'recaptcha_site_key', type="char", + string='reCAPTCHA site Key'), + 'recaptcha_private_key': fields.related( + 'website_id', 'recaptcha_private_key', type="char", + string='reCAPTCHA Private Key'), + } + diff --git a/website_recaptcha_reloaded/static/description/icon.png b/website_recaptcha_reloaded/static/description/icon.png new file mode 100644 index 0000000..5928045 Binary files /dev/null and b/website_recaptcha_reloaded/static/description/icon.png differ diff --git a/website_recaptcha_reloaded/static/description/index.html b/website_recaptcha_reloaded/static/description/index.html new file mode 100644 index 0000000..859f227 --- /dev/null +++ b/website_recaptcha_reloaded/static/description/index.html @@ -0,0 +1,13 @@ +
+
+

Odoo Website reCAPTCHA Reloaded

+

By Tech Receptives

+

+ This modules allows you to integrate Google reCAPTCHA v2.0 to your website forms. You can configure your Google reCAPTCHA site and public keys in "Settings" -> "Website Settings". +

+ +
+ +
+
+
diff --git a/website_recaptcha_reloaded/static/description/recaptcha_setting.png b/website_recaptcha_reloaded/static/description/recaptcha_setting.png new file mode 100644 index 0000000..9c6a922 Binary files /dev/null and b/website_recaptcha_reloaded/static/description/recaptcha_setting.png differ diff --git a/website_recaptcha_reloaded/views/res_config.xml b/website_recaptcha_reloaded/views/res_config.xml new file mode 100644 index 0000000..2381123 --- /dev/null +++ b/website_recaptcha_reloaded/views/res_config.xml @@ -0,0 +1,29 @@ + + + + + + Website settings + website.config.settings + + + + + + + + + + diff --git a/website_recaptcha_reloaded/views/website_view.xml b/website_recaptcha_reloaded/views/website_view.xml new file mode 100644 index 0000000..1e03868 --- /dev/null +++ b/website_recaptcha_reloaded/views/website_view.xml @@ -0,0 +1,29 @@ + + + + + + + + + website.form + website + + +
+
+ + + + + +
+
+
+
+
+
diff --git a/website_recaptcha_reloaded/website.py b/website_recaptcha_reloaded/website.py new file mode 100644 index 0000000..da23c39 --- /dev/null +++ b/website_recaptcha_reloaded/website.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Tech-Receptives Solutions Pvt. Ltd. +# Copyright (C)2004-TODAY Tech Receptives() +# +# 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 . +# +############################################################################## +from openerp.osv import osv, fields +import requests +import json + +class website(osv.osv): + _inherit = 'website' + + _columns = { + 'recaptcha_site_key': fields.char('reCAPTCHA Site Key'), + 'recaptcha_private_key': fields.char('reCAPTCHA Private Key'), + } + + + def is_captcha_valid(self, cr, uid, ids, response, context={}): + for website in self.browse(cr, uid, ids, context=context): + get_res = {'secret': website.recaptcha_private_key,'response': response} + try: + response = requests.get('https://www.google.com/recaptcha/api/siteverify', params=get_res) + except Exception,e: + raise osv.except_osv(('Invalid Data!'),("%s.")%(e)) + res_con = json.loads(response.content) + if res_con.has_key('success') and res_con['success']: + return True + return False + + _defaults = { + 'recaptcha_site_key': "6LchkgATAAAAAAdTJ_RCvTRL7_TTcN3Zm_YXB39s", + 'recaptcha_private_key': "6LchkgATAAAAADbGqMvbRxHbTnTEkavjw1gSwCng" + } \ No newline at end of file