diff --git a/apps/location/transfer_data.py b/apps/location/transfer_data.py index 47d72c72..cb8402ad 100644 --- a/apps/location/transfer_data.py +++ b/apps/location/transfer_data.py @@ -1,11 +1,11 @@ -from django.db.models import Q, QuerySet - from transfer.serializers.location import CountrySerializer, RegionSerializer, \ CitySerializer, AddressSerializer, \ Country from transfer.models import Cities, Locations from pprint import pprint +from requests import get + def transfer_countries(): queryset = Cities.objects.raw(""" @@ -135,10 +135,14 @@ def transfer_addresses(): def update_flags(): queryset = Country.objects.only("id", "code", "svg_image").filter(old_id__isnull=False) + link_to_request = "https://s3.eu-central-1.amazonaws.com/gm-test.com/media" for query in queryset: - query.svg_image = f"/image/image/10-31-2019/{query.code}.svg" - query.save() + svg_link = f"/svg/country/10-31-2019/{query.code}.svg" + resp = get(f"{link_to_request}{svg_link}") + if resp.status_code == 200: + query.svg_image = svg_link + query.save() data_types = { diff --git a/apps/utils/methods.py b/apps/utils/methods.py index bea8fec7..28ac55df 100644 --- a/apps/utils/methods.py +++ b/apps/utils/methods.py @@ -64,7 +64,7 @@ def image_path(instance, filename): def svg_image_path(instance, filename): """Determine SVG path method.""" filename = '%s.svg' % generate_code() - return 'image/svg/%s/%s/%s' % ( + return 'svg/%s/%s/%s' % ( instance._meta.model_name, datetime.now().strftime(settings.REST_DATE_FORMAT), filename) diff --git a/project/settings/development.py b/project/settings/development.py index a9cfe5be..a6f45b2f 100644 --- a/project/settings/development.py +++ b/project/settings/development.py @@ -60,4 +60,8 @@ DATABASES = { 'USER': os.environ.get('MYSQL_USER'), 'PASSWORD': os.environ.get('MYSQL_PASSWORD') } -} \ No newline at end of file +} + +BROKER_URL = 'redis://localhost:6379/1' +CELERY_RESULT_BACKEND = BROKER_URL +CELERY_BROKER_URL = BROKER_URL \ No newline at end of file