diff --git a/ivatar/ivataraccount/test_views.py b/ivatar/ivataraccount/test_views.py index a17051f..1058980 100644 --- a/ivatar/ivataraccount/test_views.py +++ b/ivatar/ivataraccount/test_views.py @@ -1228,7 +1228,7 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods response = self.client.get(url, follow=True) self.assertRedirects( response=response, - expected_url='/static/img/nobody/80.png', + expected_url='/static/img/mm/80.png', msg_prefix='Why does this not redirect to the default img?') # Eventually one should check if the data is the same @@ -1302,8 +1302,8 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods response = self.client.get(url, follow=True) self.assertRedirects( response=response, - expected_url='/static/img/nobody/80.png', - msg_prefix='Why does this not redirect to the default img?') + expected_url='/static/img/nobody.png', + msg_prefix='Why does this not redirect to nobody img?') def test_avatar_url_default_gravatarproxy_disabled(self): # pylint: disable=invalid-name ''' @@ -1339,7 +1339,7 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods response = self.client.get(url, follow=False) self.assertRedirects( response=response, - expected_url='/gravatarproxy/fb7a6d7f11365642d44ba66dc57df56f?s=80', + expected_url='/gravatarproxy/fb7a6d7f11365642d44ba66dc57df56f?s=80&default=http://host.tld/img.png', fetch_redirect_response=False, msg_prefix='Why does this not redirect to the default img?') diff --git a/ivatar/views.py b/ivatar/views.py index 300d267..f330c34 100644 --- a/ivatar/views.py +++ b/ivatar/views.py @@ -157,6 +157,10 @@ class AvatarImageView(TemplateView): 'rgb(141,69,170)'] background = 'rgb(224,224,224)' padwidth = int(size/10) + if padwidth < 10: + padwidth = 10 + if size < 60: + padwidth = 0 padding = (padwidth, padwidth, padwidth, padwidth) # Since padding is _added_ around the generated image, we # need to reduce the image size by padding*2 (left/right, top/bottom) @@ -217,7 +221,7 @@ class GravatarProxyView(View): url = reverse_lazy( 'avatar_view', args=[kwargs['digest']]) + '?s=%i' % size + '&forcedefault=y' - if default: + if default != None: url += '&default=%s' % default return HttpResponseRedirect(url) @@ -226,7 +230,8 @@ class GravatarProxyView(View): default = None try: - default = request.GET['default'] + if str(request.GET['default']) != 'None': + default = request.GET['default'] except: pass