Merge branch 'develop' of ssh://gl.id-east.ru:222/gm/gm-backend into develop
This commit is contained in:
commit
5928ee1884
|
|
@ -1,11 +1,12 @@
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import requests
|
||||||
from django.db.models import Q, F
|
from django.db.models import Q, F
|
||||||
|
|
||||||
from transfer.models import Establishments, Dishes
|
|
||||||
from transfer.serializers.establishment import EstablishmentSerializer
|
|
||||||
from establishment.models import Establishment
|
from establishment.models import Establishment
|
||||||
from location.models import Address
|
from location.models import Address
|
||||||
|
from transfer.models import Establishments, Dishes
|
||||||
|
from transfer.serializers.establishment import EstablishmentSerializer
|
||||||
from transfer.serializers.plate import PlateSerializer
|
from transfer.serializers.plate import PlateSerializer
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -126,6 +127,28 @@ 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,
|
||||||
|
|
@ -133,6 +156,6 @@ data_types = {
|
||||||
"location_establishment": [
|
"location_establishment": [
|
||||||
transfer_establishment_addresses
|
transfer_establishment_addresses
|
||||||
],
|
],
|
||||||
|
|
||||||
"menu": [transfer_menu],
|
"menu": [transfer_menu],
|
||||||
|
"fix_establishment_preview_image": [fix_establishment_preview_image],
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ 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