Browse Source

Merge pull request #254 from Endika/pr-res_users_with_gravatar

[ADD] base_user_gravatar
pull/258/head
Moises Lopez - https://www.vauxoo.com/ 9 years ago
parent
commit
2b6db90ba0
  1. 60
      base_user_gravatar/README.rst
  2. 5
      base_user_gravatar/__init__.py
  3. 18
      base_user_gravatar/__openerp__.py
  4. 40
      base_user_gravatar/i18n/es.po
  5. 40
      base_user_gravatar/i18n/res_users_with_gravatar.pot
  6. 5
      base_user_gravatar/models/__init__.py
  7. 38
      base_user_gravatar/models/res_users.py
  8. BIN
      base_user_gravatar/static/description/icon.png
  9. 29
      base_user_gravatar/views/res_users_view.xml

60
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 <https://github.com/OCA/server-tools/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 <https://github.com/OCA/{project_repo}/issues/new?body=module:%20base_user_gravatar%0Aversion:%201%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Endika Iglesias <endika2@gmail.com>
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.

5
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

18
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',
],
}

40
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)"

40
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 ""

5
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

38
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

BIN
base_user_gravatar/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 14 KiB

29
base_user_gravatar/views/res_users_view.xml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_users_form_simple_modif_gravatar" model="ir.ui.view">
<field name="name">res.users.form.gravatar</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
<field name="arch" type="xml">
<field name="name" position="after">
<button name="get_gravatar_image" type="object" string="Get Gravatar image" class="oe_edit_only"/>
</field>
</field>
</record>
<record id="view_users_form_gravatar" model="ir.ui.view">
<field name="name">res.users.form.gravatar</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<field name="login" position="after">
<button name="get_gravatar_image" type="object" string="Get Gravatar image" class="oe_edit_only"/>
</field>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save