From d780894d80bdc7ac7cd2931420ec973e0258e3b0 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 25 May 2018 10:55:32 +0200 Subject: [PATCH] Error when trying to fetch with openid --- ivatar/views.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ivatar/views.py b/ivatar/views.py index a034073..3e43fa0 100644 --- a/ivatar/views.py +++ b/ivatar/views.py @@ -26,10 +26,12 @@ class AvatarImageView(TemplateView): else: raise Exception('Digest provided is wrong: %s' % kwargs['digest']) - email = model.objects.get(digest=kwargs['digest']) - if not email.photo: - raise Exception('No photo assigned to "%s"' % email.email) + obj = model.objects.get(digest=kwargs['digest']) + if not obj.photo: + # That is hacky, but achieves what we want :-) + attr = getattr(obj, 'email', obj.openid) + raise Exception('No photo assigned to "%s"' % attr) return HttpResponse( - io.BytesIO(email.photo.data), - content_type='image/%s' % email.photo.format) + io.BytesIO(obj.photo.data), + content_type='image/%s' % obj.photo.format)