added fix link for establishment preview_image
This commit is contained in:
parent
5928ee1884
commit
4e76fc966e
|
|
@ -18,14 +18,16 @@ class Command(BaseCommand):
|
||||||
AND scope = 'public'
|
AND scope = 'public'
|
||||||
AND type = 'Photo'
|
AND type = 'Photo'
|
||||||
AND menu_id IS NULL
|
AND menu_id IS NULL
|
||||||
GROUP BY establishment_id;'''
|
GROUP BY establishment_id, establishment_assets.id, establishment_id, attachment_suffix_url;'''
|
||||||
)
|
)
|
||||||
queryset = [vars(query) for query in raw_qs]
|
queryset = [vars(query) for query in raw_qs]
|
||||||
for obj in queryset:
|
for obj in queryset:
|
||||||
establishment = Establishment.objects.filter(old_id=obj['establishment_id']).first()
|
establishment = Establishment.objects.filter(old_id=obj['establishment_id']).first()
|
||||||
if establishment:
|
if establishment:
|
||||||
img = url + obj['attachment_suffix_url']
|
img = url + obj['attachment_suffix_url']
|
||||||
establishment.preview_image_url = img
|
img_url = img[:-12]
|
||||||
|
extension = img.split('.')[-1:][0] # JPG
|
||||||
|
establishment.preview_image_url = f'{img_url}xlarge.{extension}'
|
||||||
establishment.image_url = img
|
establishment.image_url = img
|
||||||
establishment.save()
|
establishment.save()
|
||||||
count += 1
|
count += 1
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,8 @@ from transfer.serializers.plate import PlateSerializer
|
||||||
def transfer_establishment():
|
def transfer_establishment():
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
old_establishments = Establishments.objects.filter(
|
# todo: filter(location__city__name__icontains='paris')
|
||||||
location__city__name__icontains='paris',
|
old_establishments = Establishments.objects.exclude(
|
||||||
).exclude(
|
|
||||||
Q(type='Wineyard') |
|
Q(type='Wineyard') |
|
||||||
Q(location__timezone__isnull=True)
|
Q(location__timezone__isnull=True)
|
||||||
).prefetch_related(
|
).prefetch_related(
|
||||||
|
|
@ -127,28 +126,6 @@ def transfer_establishment_addresses():
|
||||||
establishment.save()
|
establishment.save()
|
||||||
|
|
||||||
|
|
||||||
def fix_establishment_preview_image():
|
|
||||||
|
|
||||||
updated = 0
|
|
||||||
not_updated = 0
|
|
||||||
|
|
||||||
qs = Establishment.objects.filter(image_url__isnull=False,
|
|
||||||
preview_image_url__isnull=False,
|
|
||||||
old_id__isnull=False)
|
|
||||||
for e in qs:
|
|
||||||
image_urlpath_1 = e.preview_image_url.__str__()[:-12] # https://.../gaultmillau.com/photos/.../
|
|
||||||
extension = e.preview_image_url.__str__().split('.')[-1:][0] # JPG
|
|
||||||
image_urlpath_complete = f'{image_urlpath_1}xlarge.{extension}'
|
|
||||||
response = requests.head(image_urlpath_complete)
|
|
||||||
if response.status_code == 200:
|
|
||||||
e.preview_image_url = image_urlpath_complete
|
|
||||||
e.save()
|
|
||||||
updated += 1
|
|
||||||
else:
|
|
||||||
not_updated += 1
|
|
||||||
print(f'updated: {updated}\nnot_updated: {not_updated}')
|
|
||||||
|
|
||||||
|
|
||||||
data_types = {
|
data_types = {
|
||||||
"establishment": [
|
"establishment": [
|
||||||
transfer_establishment,
|
transfer_establishment,
|
||||||
|
|
@ -157,5 +134,4 @@ data_types = {
|
||||||
transfer_establishment_addresses
|
transfer_establishment_addresses
|
||||||
],
|
],
|
||||||
"menu": [transfer_menu],
|
"menu": [transfer_menu],
|
||||||
"fix_establishment_preview_image": [fix_establishment_preview_image],
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
LONG_DATA_TYPES = [
|
LONG_DATA_TYPES = [
|
||||||
'update_country_flag',
|
'update_country_flag',
|
||||||
'fix_establishment_preview_image'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user