Skip to content

Commit

Permalink
Replace request of static files with internal files (#7992)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoek1 authored Dec 2, 2020
1 parent bee72ae commit a862c7a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/grants/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ def generate_collection_thumbnail(collection, width, heigth):
if grant.logo:
if len(logos) > DISPLAY_GRANTS_LIMIT:
break

fd = urllib.request.urlopen(f'{media_url}{grant.logo.url}')
grant_url = f'{media_url}{grant.logo.url}'
print(f'Trying to get: ${grant_url}')
fd = urllib.request.urlopen(grant_url)
logos.append(fd)
else:
static_file = static(f'/v2/images/grants/logos/{grant.id % 3}.png')
logo = urllib.request.urlopen(f'{STATIC_HOST[:-1]}{static_file}')
logos.append(logo)
static_file = f'assets/v2/images/grants/logos/{grant.id % 3}.png'
logos.append(static_file)

for logo in range(len(logos), 4):
logos.append(None)
Expand Down Expand Up @@ -242,7 +242,7 @@ def generate_collection_thumbnail(collection, width, heigth):
thumbail.paste(grant_bg, CORNERS[index], grant_bg)
continue

if re.match(r'.*\.svg', logos[index].url):
if type(logos[index]) is not str and re.match(r'.*\.svg', logos[index].url):
grant_img = convert_img(logos[index])
grant_thumbail = Image.open(grant_img)
else:
Expand Down

0 comments on commit a862c7a

Please sign in to comment.