Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use requests to fetch event and speaker images #6639

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/api/helpers/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import urllib.parse
import urllib.request
import uuid
import requests

import PIL
from PIL import Image
Expand Down Expand Up @@ -77,7 +78,7 @@ def create_save_resized_image(image_file, basewidth=None, maintain_aspect=None,
if not image_file:
return None
filename = '{filename}.{ext}'.format(filename=get_file_name(), ext=ext)
data = urllib.request.urlopen(image_file).read()
data = requests.get(image_file).content
image_file = io.BytesIO(data)
try:
im = Image.open(image_file)
Expand Down Expand Up @@ -129,7 +130,14 @@ def create_save_image_sizes(image_file, image_sizes_type, unique_identifier=None
try:
image_sizes = ImageSizes.query.filter_by(type=image_sizes_type).one()
except NoResultFound:
image_sizes = ImageSizes(image_sizes_type, 1300, 500, True, 100, 75, 30, True, 100, 500, 200, True, 100)
image_sizes = ImageSizes(image_sizes_type, full_width=1300,
full_height=500, full_aspect=True, full_quality=80,
icon_width=75, icon_height=30, icon_aspect=True,
icon_quality=80, thumbnail_width=500, thumbnail_height=200,
thumbnail_aspect=True, thumbnail_quality=80, logo_width=500,
logo_height=200, icon_size_width_height=35, icon_size_quality=80,
small_size_width_height=50, small_size_quality=80,
thumbnail_size_width_height=500)

# Get an unique identifier from uuid if not provided
if unique_identifier is None:
Expand Down
9 changes: 3 additions & 6 deletions docs/api/blueprint/user/users.apib
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Create a new user using an email, password and an optional name.
{
"email": "[email protected]",
"password": "password",
"avatar_url": "http://example.com/example.png",
"avatar_url": "https://avatars2.githubusercontent.com/u/1583873",
"first-name": "John",
"last-name": "Doe",
"details": "example",
Expand Down Expand Up @@ -550,18 +550,15 @@ Authorized user should be same as user in request body or must be admin.
"data": {
"attributes": {
"password": "password",
"avatar_url": "http://example.com/example.png",
"avatar_url": "https://avatars2.githubusercontent.com/u/1583873",
"first-name": "John",
"last-name": "Doe",
"details": "example1",
"contact": "example1",
"facebook-url": "http://facebook.com/facebook",
"twitter-url": "http://twitter.com/twitter",
"instagram-url": "http://instagram.com/instagram",
"google-plus-url": "http://plus.google.com/plus.google",
"thumbnail-image-url": "http://example.com/example.png",
"small-image-url": "http://example.com/example.png",
"icon-image-url": "http://example.com/example.png"
"google-plus-url": "http://plus.google.com/plus.google"
},
"type": "user",
"id": "2"
Expand Down