diff --git a/base_user_gravatar/README.rst b/base_user_gravatar/README.rst new file mode 100644 index 000000000..1f62a8143 --- /dev/null +++ b/base_user_gravatar/README.rst @@ -0,0 +1,60 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +========================== +Synchronize Gravatar image +========================== + +Use you Gravatar image in to your Odoo + +Usage +===== + +To configure this module, you need to: + +* go to user profile +* press "Get Gravatar image" button + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/149/8.0 + +.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt +.. branch is "8.0" for example + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Endika Iglesias + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/base_user_gravatar/__init__.py b/base_user_gravatar/__init__.py new file mode 100644 index 000000000..c2c2899c9 --- /dev/null +++ b/base_user_gravatar/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Endika Iglesias +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/base_user_gravatar/__openerp__.py b/base_user_gravatar/__openerp__.py new file mode 100644 index 000000000..a86b9d54c --- /dev/null +++ b/base_user_gravatar/__openerp__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © 2015 Endika Iglesias +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Synchronize Gravatar image', + 'version': '8.0.1.0.0', + 'author': 'Endika Iglesias, Odoo Community Association (OCA)', + 'category': 'Tools', + 'website': 'http://www.endikaiglesias.com/', + "license": "AGPL-3", + "application": False, + "installable": True, + 'depends': ['base'], + 'data': [ + 'views/res_users_view.xml', + ], +} diff --git a/base_user_gravatar/i18n/es.po b/base_user_gravatar/i18n/es.po new file mode 100644 index 000000000..003fafcb0 --- /dev/null +++ b/base_user_gravatar/i18n/es.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * res_users_with_gravatar +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-18 10:53+0000\n" +"PO-Revision-Date: 2015-09-18 10:53+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: res_users_with_gravatar +#: view:res.users:res_users_with_gravatar.view_users_form_gravatar +#: view:res.users:res_users_with_gravatar.view_users_form_simple_modif_gravatar +msgid "Get Gravatar image" +msgstr "Obtener imagen de Gravatar" + +#. module: res_users_with_gravatar +#: code:addons/res_users_with_gravatar/models/res_users.py:25 +#, python-format +msgid "Sorry Gravatar not found." +msgstr "Lo siento, Gravatar no funciona." + +#. module: res_users_with_gravatar +#: model:ir.model,name:res_users_with_gravatar.model_res_users +msgid "Users" +msgstr "Usuarios" + +#. module: res_users_with_gravatar +#: code:addons/res_users_with_gravatar/models/res_users.py:36 +#, python-format +msgid "There is no Gravatar image for this email (%s)" +msgstr "No hay imagen de Gravatar para este email (%s)" + diff --git a/base_user_gravatar/i18n/res_users_with_gravatar.pot b/base_user_gravatar/i18n/res_users_with_gravatar.pot new file mode 100644 index 000000000..908b533a2 --- /dev/null +++ b/base_user_gravatar/i18n/res_users_with_gravatar.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * res_users_with_gravatar +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-18 10:53+0000\n" +"PO-Revision-Date: 2015-09-18 10:53+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: res_users_with_gravatar +#: view:res.users:res_users_with_gravatar.view_users_form_gravatar +#: view:res.users:res_users_with_gravatar.view_users_form_simple_modif_gravatar +msgid "Get Gravatar image" +msgstr "" + +#. module: res_users_with_gravatar +#: code:addons/res_users_with_gravatar/models/res_users.py:25 +#, python-format +msgid "Sorry Gravatar not found." +msgstr "" + +#. module: res_users_with_gravatar +#: model:ir.model,name:res_users_with_gravatar.model_res_users +msgid "Users" +msgstr "" + +#. module: res_users_with_gravatar +#: code:addons/res_users_with_gravatar/models/res_users.py:36 +#, python-format +msgid "There is no Gravatar image for this email (%s)" +msgstr "" + diff --git a/base_user_gravatar/models/__init__.py b/base_user_gravatar/models/__init__.py new file mode 100644 index 000000000..1d2e86699 --- /dev/null +++ b/base_user_gravatar/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Endika Iglesias +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import res_users diff --git a/base_user_gravatar/models/res_users.py b/base_user_gravatar/models/res_users.py new file mode 100644 index 000000000..8874f3585 --- /dev/null +++ b/base_user_gravatar/models/res_users.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# © 2015 Endika Iglesias +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import base64 +import hashlib +import urllib2 + +from openerp import api, models +from openerp.exceptions import Warning as UserError +from openerp.tools.translate import _ + + +class ResUsers(models.Model): + _inherit = 'res.users' + + def _get_gravatar_base64(self, email=''): + url = 'http://www.gravatar.com/avatar/{}?s=200' + _hash = hashlib.md5(email).hexdigest() + try: + res = urllib2.urlopen(url.format(_hash)) + raw_image = res.read() + return base64.encodestring(raw_image) + except urllib2.HTTPError: + raise UserError(_('Sorry Gravatar not found.')) + + @api.one + def get_gravatar_image(self): + email = str(self.email) or '' + fail_example = self._get_gravatar_base64('fail@email.gravatar') + user_gravatar = self._get_gravatar_base64(email) + if fail_example != user_gravatar: + self.write({'image': user_gravatar}) + else: + raise UserError( + _("There is no Gravatar image for this email (%s)" % ( + email))) + return True diff --git a/base_user_gravatar/static/description/icon.png b/base_user_gravatar/static/description/icon.png new file mode 100644 index 000000000..871a69c18 Binary files /dev/null and b/base_user_gravatar/static/description/icon.png differ diff --git a/base_user_gravatar/views/res_users_view.xml b/base_user_gravatar/views/res_users_view.xml new file mode 100644 index 000000000..48ff4e5ae --- /dev/null +++ b/base_user_gravatar/views/res_users_view.xml @@ -0,0 +1,29 @@ + + + + + + res.users.form.gravatar + res.users + + + +