mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-17 13:38:03 +00:00
Merge branch 'devel' into 'master'
Pull in latest fixes from default - esp. in regards to default image handling (in combination with GravatarProxy) Closes #45 and #48 See merge request oliver/ivatar!113
This commit is contained in:
@@ -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?')
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user