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 devel Closes #49 See merge request oliver/ivatar!126
This commit is contained in:
@@ -37,10 +37,10 @@ from .gravatar import get_photo as get_gravatar_photo
|
|||||||
|
|
||||||
def file_format(image_type):
|
def file_format(image_type):
|
||||||
'''
|
'''
|
||||||
Helper method returning a 3 character long image type
|
Helper method returning a short image type
|
||||||
'''
|
'''
|
||||||
if image_type == 'JPEG':
|
if image_type == 'JPEG':
|
||||||
return 'jpg'
|
return 'jpeg'
|
||||||
elif image_type == 'PNG':
|
elif image_type == 'PNG':
|
||||||
return 'png'
|
return 'png'
|
||||||
elif image_type == 'GIF':
|
elif image_type == 'GIF':
|
||||||
@@ -52,7 +52,7 @@ def pil_format(image_type):
|
|||||||
'''
|
'''
|
||||||
Helper method returning the 'encoder name' for PIL
|
Helper method returning the 'encoder name' for PIL
|
||||||
'''
|
'''
|
||||||
if image_type == 'jpg':
|
if image_type == 'jpg' or image_type == 'jpeg':
|
||||||
return 'JPEG'
|
return 'JPEG'
|
||||||
elif image_type == 'png':
|
elif image_type == 'png':
|
||||||
return 'PNG'
|
return 'PNG'
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
# Probably not the best way to access the content type
|
# Probably not the best way to access the content type
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response['Content-Type'],
|
response['Content-Type'],
|
||||||
'image/jpg',
|
'image/jpeg',
|
||||||
'Content type wrong!?')
|
'Content type wrong!?')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@@ -638,10 +638,10 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
str(list(response.context[0]['messages'])[0]),
|
str(list(response.context[0]['messages'])[0]),
|
||||||
'Successfully uploaded',
|
'Successfully uploaded',
|
||||||
'JPG upload failed?!')
|
'JPEG upload failed?!')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.user.photo_set.first().format, 'jpg',
|
self.user.photo_set.first().format, 'jpeg',
|
||||||
'Format must be jpg, since we uploaded a jpg!')
|
'Format must be jpeg, since we uploaded a jpeg!')
|
||||||
self.test_confirm_email()
|
self.test_confirm_email()
|
||||||
self.user.confirmedemail_set.first().photo = self.user.photo_set.first()
|
self.user.confirmedemail_set.first().photo = self.user.photo_set.first()
|
||||||
urlobj = urlsplit(
|
urlobj = urlsplit(
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from PIL import Image
|
|||||||
from monsterid.id import build_monster as BuildMonster
|
from monsterid.id import build_monster as BuildMonster
|
||||||
import Identicon
|
import Identicon
|
||||||
from pydenticon5 import Pydenticon5
|
from pydenticon5 import Pydenticon5
|
||||||
|
import pagan
|
||||||
from robohash import Robohash
|
from robohash import Robohash
|
||||||
|
|
||||||
from ivatar.settings import AVATAR_MAX_SIZE, JPEG_QUALITY, DEFAULT_AVATAR_SIZE
|
from ivatar.settings import AVATAR_MAX_SIZE, JPEG_QUALITY, DEFAULT_AVATAR_SIZE
|
||||||
@@ -166,6 +166,16 @@ class AvatarImageView(TemplateView):
|
|||||||
data,
|
data,
|
||||||
content_type='image/png')
|
content_type='image/png')
|
||||||
|
|
||||||
|
if str(default) == 'pagan':
|
||||||
|
paganobj = pagan.Avatar(kwargs['digest'])
|
||||||
|
data = BytesIO()
|
||||||
|
img = paganobj.img.resize((size, size), Image.ANTIALIAS)
|
||||||
|
img.save(data, 'PNG', quality=JPEG_QUALITY)
|
||||||
|
data.seek(0)
|
||||||
|
return HttpResponse(
|
||||||
|
data,
|
||||||
|
content_type='image/png')
|
||||||
|
|
||||||
if str(default) == 'identicon':
|
if str(default) == 'identicon':
|
||||||
p = Pydenticon5()
|
p = Pydenticon5()
|
||||||
# In order to make use of the whole 32 bytes digest, we need to redigest them.
|
# In order to make use of the whole 32 bytes digest, we need to redigest them.
|
||||||
|
|||||||
@@ -37,3 +37,4 @@ git+https://github.com/ofalk/Robohash.git@devel
|
|||||||
python-memcached
|
python-memcached
|
||||||
git+https://github.com/ercpe/pydenticon5.git
|
git+https://github.com/ercpe/pydenticon5.git
|
||||||
git+https://github.com/flavono123/identicon.git
|
git+https://github.com/flavono123/identicon.git
|
||||||
|
pagan
|
||||||
|
|||||||
Reference in New Issue
Block a user