Added live link part
This commit is contained in:
parent
0a832136d3
commit
294c468405
|
|
@ -56,10 +56,14 @@ def update_establishment_image_urls(part_number: int, summary_tasks: int, bucket
|
||||||
queryset = Establishment.objects.filter(id__in=bucket_ids)
|
queryset = Establishment.objects.filter(id__in=bucket_ids)
|
||||||
|
|
||||||
for establishment in queryset:
|
for establishment in queryset:
|
||||||
for data in [
|
live_link = None
|
||||||
|
|
||||||
|
image_urls = [
|
||||||
('image_url', establishment.image_url),
|
('image_url', establishment.image_url),
|
||||||
('preview_image_url', establishment.preview_image_url)
|
('preview_image_url', establishment.preview_image_url)
|
||||||
]:
|
]
|
||||||
|
|
||||||
|
for data in image_urls:
|
||||||
attr, url = data
|
attr, url = data
|
||||||
|
|
||||||
if establishment.image_url is not None:
|
if establishment.image_url is not None:
|
||||||
|
|
@ -69,11 +73,21 @@ def update_establishment_image_urls(part_number: int, summary_tasks: int, bucket
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
setattr(establishment, attr, None)
|
setattr(establishment, attr, None)
|
||||||
|
|
||||||
|
else:
|
||||||
|
live_link = url
|
||||||
|
|
||||||
except (
|
except (
|
||||||
requests.exceptions.ConnectionError,
|
requests.exceptions.ConnectionError,
|
||||||
requests.exceptions.ConnectTimeout
|
requests.exceptions.ConnectTimeout
|
||||||
):
|
):
|
||||||
setattr(establishment, attr, None)
|
setattr(establishment, attr, None)
|
||||||
|
|
||||||
|
if live_link is not None:
|
||||||
|
if establishment.image_url is None:
|
||||||
|
establishment.image_url = live_link
|
||||||
|
|
||||||
|
elif establishment.preview_image_url is None:
|
||||||
|
establishment.preview_image_url = live_link
|
||||||
|
|
||||||
logger.info(f'The {part_number}th part of the image update '
|
logger.info(f'The {part_number}th part of the image update '
|
||||||
f'from {summary_tasks} parts was completed')
|
f'from {summary_tasks} parts was completed')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user