mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-17 21:48:02 +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)
|
response = self.client.get(url, follow=True)
|
||||||
self.assertRedirects(
|
self.assertRedirects(
|
||||||
response=response,
|
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?')
|
msg_prefix='Why does this not redirect to the default img?')
|
||||||
# Eventually one should check if the data is the same
|
# 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)
|
response = self.client.get(url, follow=True)
|
||||||
self.assertRedirects(
|
self.assertRedirects(
|
||||||
response=response,
|
response=response,
|
||||||
expected_url='/static/img/nobody/80.png',
|
expected_url='/static/img/nobody.png',
|
||||||
msg_prefix='Why does this not redirect to the default img?')
|
msg_prefix='Why does this not redirect to nobody img?')
|
||||||
|
|
||||||
def test_avatar_url_default_gravatarproxy_disabled(self): # pylint: disable=invalid-name
|
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)
|
response = self.client.get(url, follow=False)
|
||||||
self.assertRedirects(
|
self.assertRedirects(
|
||||||
response=response,
|
response=response,
|
||||||
expected_url='/gravatarproxy/fb7a6d7f11365642d44ba66dc57df56f?s=80',
|
expected_url='/gravatarproxy/fb7a6d7f11365642d44ba66dc57df56f?s=80&default=http://host.tld/img.png',
|
||||||
fetch_redirect_response=False,
|
fetch_redirect_response=False,
|
||||||
msg_prefix='Why does this not redirect to the default img?')
|
msg_prefix='Why does this not redirect to the default img?')
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,10 @@ class AvatarImageView(TemplateView):
|
|||||||
'rgb(141,69,170)']
|
'rgb(141,69,170)']
|
||||||
background = 'rgb(224,224,224)'
|
background = 'rgb(224,224,224)'
|
||||||
padwidth = int(size/10)
|
padwidth = int(size/10)
|
||||||
|
if padwidth < 10:
|
||||||
|
padwidth = 10
|
||||||
|
if size < 60:
|
||||||
|
padwidth = 0
|
||||||
padding = (padwidth, padwidth, padwidth, padwidth)
|
padding = (padwidth, padwidth, padwidth, padwidth)
|
||||||
# Since padding is _added_ around the generated image, we
|
# Since padding is _added_ around the generated image, we
|
||||||
# need to reduce the image size by padding*2 (left/right, top/bottom)
|
# need to reduce the image size by padding*2 (left/right, top/bottom)
|
||||||
@@ -217,7 +221,7 @@ class GravatarProxyView(View):
|
|||||||
url = reverse_lazy(
|
url = reverse_lazy(
|
||||||
'avatar_view',
|
'avatar_view',
|
||||||
args=[kwargs['digest']]) + '?s=%i' % size + '&forcedefault=y'
|
args=[kwargs['digest']]) + '?s=%i' % size + '&forcedefault=y'
|
||||||
if default:
|
if default != None:
|
||||||
url += '&default=%s' % default
|
url += '&default=%s' % default
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
@@ -226,6 +230,7 @@ class GravatarProxyView(View):
|
|||||||
default = None
|
default = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if str(request.GET['default']) != 'None':
|
||||||
default = request.GET['default']
|
default = request.GET['default']
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user