Endika Iglesias García
9 years ago
9 changed files with 225 additions and 0 deletions
-
33res_users_with_gravatar/README.rst
-
6res_users_with_gravatar/__init__.py
-
34res_users_with_gravatar/__openerp__.py
-
40res_users_with_gravatar/i18n/es.po
-
40res_users_with_gravatar/i18n/res_users_with_gravatar.pot
-
6res_users_with_gravatar/models/__init__.py
-
38res_users_with_gravatar/models/res_users.py
-
BINres_users_with_gravatar/static/description/icon.png
-
28res_users_with_gravatar/views/res_users_view.xml
@ -0,0 +1,33 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:alt: License: AGPL-3 |
|||
|
|||
Synchronize Gravatar image |
|||
========================== |
|||
|
|||
Use you Gravatar image in to your Odoo |
|||
|
|||
|
|||
License |
|||
======= |
|||
|
|||
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/agpl-3.0-standalone.html>. |
|||
|
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Endika Iglesias <endika2@gmail.com> |
@ -0,0 +1,6 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# For copyright and license notices, see __openerp__.py file in root directory |
|||
############################################################################## |
|||
|
|||
from . import models |
@ -0,0 +1,34 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright : |
|||
# Endika Iglesias <endika2@gmail.com> |
|||
# |
|||
# 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': 'Synchronize Gravatar image', |
|||
'version': '1', |
|||
'author': 'Endika Iglesias', |
|||
'category': 'Tools', |
|||
'website': 'http://www.endikaiglesias.com', |
|||
'depends': ['base'], |
|||
'data': [ |
|||
'views/res_users_view.xml', |
|||
], |
|||
'installable': True, |
|||
} |
@ -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 "You don't have Gravatar image to this %s email." |
|||
msgstr "No tiene imagen de Gravatar para este %s email." |
|||
|
@ -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 "You don't have Gravatar image to this %s email." |
|||
msgstr "" |
|||
|
@ -0,0 +1,6 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# For copyright and license notices, see __openerp__.py file in root directory |
|||
############################################################################## |
|||
|
|||
from . import res_users |
@ -0,0 +1,38 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# For copyright and license notices, see __openerp__.py file in root directory |
|||
############################################################################## |
|||
|
|||
from openerp import models, api |
|||
from openerp.exceptions import Warning |
|||
from openerp.tools.translate import _ |
|||
import base64 |
|||
import hashlib |
|||
import urllib2 |
|||
|
|||
|
|||
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 Warning(_('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 Warning( |
|||
_("You don't have Gravatar image to this %s email." % ( |
|||
email))) |
|||
return True |
After Width: 128 | Height: 128 | Size: 14 KiB |
@ -0,0 +1,28 @@ |
|||
<?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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue