Browse Source

[UPDATE]

pull/254/head
Endika Iglesias García 9 years ago
parent
commit
c7e4fa26a1
  1. 11
      base_user_gravatar/models/res_users.py

11
base_user_gravatar/models/res_users.py

@ -2,13 +2,14 @@
# © 2015 Endika Iglesias # © 2015 Endika Iglesias
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, api
from openerp.exceptions import Warning
from openerp.tools.translate import _
import base64 import base64
import hashlib import hashlib
import urllib2 import urllib2
from openerp import api, models
from openerp.exceptions import Warning as UserError
from openerp.tools.translate import _
class ResUsers(models.Model): class ResUsers(models.Model):
_inherit = 'res.users' _inherit = 'res.users'
@ -21,7 +22,7 @@ class ResUsers(models.Model):
raw_image = res.read() raw_image = res.read()
return base64.encodestring(raw_image) return base64.encodestring(raw_image)
except urllib2.HTTPError: except urllib2.HTTPError:
raise Warning(_('Sorry Gravatar not found.'))
raise UserError(_('Sorry Gravatar not found.'))
@api.one @api.one
def get_gravatar_image(self): def get_gravatar_image(self):
@ -31,7 +32,7 @@ class ResUsers(models.Model):
if fail_example != user_gravatar: if fail_example != user_gravatar:
self.write({'image': user_gravatar}) self.write({'image': user_gravatar})
else: else:
raise Warning(
raise UserError(
_("There is no Gravatar image for this email (%s)" % ( _("There is no Gravatar image for this email (%s)" % (
email))) email)))
return True return True
Loading…
Cancel
Save