mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-30 12:00:36 +00:00
Merge pull request #272 from mouse-reeve/avatars
Fixes weirdness in handling avatars
This commit is contained in:
commit
f824f0f34e
2 changed files with 8 additions and 2 deletions
|
@ -84,7 +84,8 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
if self.avatar:
|
if self.avatar:
|
||||||
url = self.avatar.url
|
url = self.avatar.url
|
||||||
else:
|
else:
|
||||||
url = 'https://%s/static/images/default_avi.jpg' % DOMAIN
|
url = '/static/images/default_avi.jpg'
|
||||||
|
url = 'https://%s%s' % (DOMAIN, url)
|
||||||
return activitypub.Image(url=url)
|
return activitypub.Image(url=url)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
''' views for actions you can take in the application '''
|
''' views for actions you can take in the application '''
|
||||||
from io import BytesIO, TextIOWrapper
|
from io import BytesIO, TextIOWrapper
|
||||||
|
from uuid import uuid4
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
@ -201,8 +202,12 @@ def edit_profile(request):
|
||||||
output = BytesIO()
|
output = BytesIO()
|
||||||
cropped.save(output, format=image.format)
|
cropped.save(output, format=image.format)
|
||||||
ContentFile(output.getvalue())
|
ContentFile(output.getvalue())
|
||||||
|
|
||||||
|
# set the name to a hash
|
||||||
|
extension = form.files['avatar'].name.split('.')[-1]
|
||||||
|
filename = '%s.%s' % (uuid4(), extension)
|
||||||
request.user.avatar.save(
|
request.user.avatar.save(
|
||||||
form.files['avatar'].name,
|
filename,
|
||||||
ContentFile(output.getvalue())
|
ContentFile(output.getvalue())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue