updated
This commit is contained in:
parent
0fb28467fb
commit
52872ce364
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -26,3 +26,5 @@ logs/
|
||||||
celerybeat-schedule
|
celerybeat-schedule
|
||||||
local_files
|
local_files
|
||||||
celerybeat.pid
|
celerybeat.pid
|
||||||
|
/gm_viktor.dump
|
||||||
|
/docker-compose.dump.yml
|
||||||
|
|
|
||||||
|
|
@ -257,16 +257,15 @@ class GuideFilterSerializer(TransferSerializerMixin):
|
||||||
for country_code_alpha_3 in regions:
|
for country_code_alpha_3 in regions:
|
||||||
for region_code_alpha_3 in regions[country_code_alpha_3]:
|
for region_code_alpha_3 in regions[country_code_alpha_3]:
|
||||||
# Get region from sub region code.
|
# Get region from sub region code.
|
||||||
if not sub_regions or country_code_alpha_3 not in sub_regions:
|
if sub_regions and country_code_alpha_3 in sub_regions:
|
||||||
raise serializers.ValidationError({'detail': f'Sub regions is blanked.'})
|
if region_code_alpha_3 in sub_regions[country_code_alpha_3]:
|
||||||
if region_code_alpha_3 in sub_regions[country_code_alpha_3]:
|
for sub_region_code_alpha_3 in sub_regions[country_code_alpha_3][region_code_alpha_3]:
|
||||||
for sub_region_code_alpha_3 in sub_regions[country_code_alpha_3][region_code_alpha_3]:
|
region = self.get_region(
|
||||||
region = self.get_region(
|
region_code_alpha_3=region_code_alpha_3,
|
||||||
region_code_alpha_3=region_code_alpha_3,
|
country_code_alpha_3=country_code_alpha_3,
|
||||||
country_code_alpha_3=country_code_alpha_3,
|
sub_region_code_alpha_3=sub_region_code_alpha_3)
|
||||||
sub_region_code_alpha_3=sub_region_code_alpha_3)
|
if region:
|
||||||
if region:
|
region_ids.append(region.id)
|
||||||
region_ids.append(region.id)
|
|
||||||
return {'id': region_ids}
|
return {'id': region_ids}
|
||||||
|
|
||||||
def get_sub_region_ids(self, sub_regions):
|
def get_sub_region_ids(self, sub_regions):
|
||||||
|
|
@ -274,28 +273,30 @@ class GuideFilterSerializer(TransferSerializerMixin):
|
||||||
if sub_regions:
|
if sub_regions:
|
||||||
for country_code_alpha_3 in sub_regions:
|
for country_code_alpha_3 in sub_regions:
|
||||||
# FRA etc.
|
# FRA etc.
|
||||||
for region_code_alpha_3 in sub_regions[country_code_alpha_3]:
|
if country_code_alpha_3 in sub_regions:
|
||||||
# B, C, A etc.
|
for region_code_alpha_3 in sub_regions[country_code_alpha_3]:
|
||||||
for sub_region_code_alpha_3 in sub_regions[country_code_alpha_3][region_code_alpha_3]:
|
# B, C, A etc.
|
||||||
# 24, 32 etc.
|
if region_code_alpha_3 in sub_regions[country_code_alpha_3]:
|
||||||
# Get parent region
|
for sub_region_code_alpha_3 in sub_regions[country_code_alpha_3][region_code_alpha_3]:
|
||||||
region = self.get_region(
|
# 24, 32 etc.
|
||||||
region_code_alpha_3=region_code_alpha_3,
|
# Get parent region
|
||||||
country_code_alpha_3=country_code_alpha_3,
|
region = self.get_region(
|
||||||
sub_region_code_alpha_3=sub_region_code_alpha_3)
|
region_code_alpha_3=region_code_alpha_3,
|
||||||
if region:
|
country_code_alpha_3=country_code_alpha_3,
|
||||||
sub_region_qs = Region.objects.filter(parent_region__code=region.code)
|
sub_region_code_alpha_3=sub_region_code_alpha_3)
|
||||||
if sub_region_qs.exists():
|
if region:
|
||||||
sub_region_ids.append(sub_region_qs.first().id)
|
sub_region_qs = Region.objects.filter(parent_region__code=region.code)
|
||||||
else:
|
if sub_region_qs.exists():
|
||||||
subdivision = subdivisions.get(code=region.code.upper())
|
sub_region_ids.append(sub_region_qs.first().id)
|
||||||
if subdivision:
|
else:
|
||||||
sub_region = Region.objects.get_or_create(
|
subdivision = subdivisions.get(code=region.code.upper())
|
||||||
name=subdivision.name,
|
if subdivision:
|
||||||
code=subdivisions.parent_code,
|
sub_region = Region.objects.get_or_create(
|
||||||
parent_region=region,
|
name=subdivision.name,
|
||||||
country=region.country)
|
code=subdivisions.parent_code,
|
||||||
sub_region_ids.append(sub_region.id)
|
parent_region=region,
|
||||||
|
country=region.country)
|
||||||
|
sub_region_ids.append(sub_region.id)
|
||||||
return {'id': set(sub_region_ids)}
|
return {'id': set(sub_region_ids)}
|
||||||
|
|
||||||
def get_wine_region_ids(self, wine_regions):
|
def get_wine_region_ids(self, wine_regions):
|
||||||
|
|
@ -316,7 +317,7 @@ class GuideFilterSerializer(TransferSerializerMixin):
|
||||||
qs = Language.objects.filter(locale=locale)
|
qs = Language.objects.filter(locale=locale)
|
||||||
if not qs.exists():
|
if not qs.exists():
|
||||||
raise serializers.ValidationError({
|
raise serializers.ValidationError({
|
||||||
'detail': f'{locale} is not found.'})
|
'detail': f'Language with locale - {locale}, is not found.'})
|
||||||
return {'id': set(locale_ids)}
|
return {'id': set(locale_ids)}
|
||||||
|
|
||||||
def get_review_state(self, states):
|
def get_review_state(self, states):
|
||||||
|
|
@ -332,7 +333,6 @@ class GuideFilterSerializer(TransferSerializerMixin):
|
||||||
def get_guide(self, old_guide_id: int):
|
def get_guide(self, old_guide_id: int):
|
||||||
qs = Guide.objects.filter(old_id=old_guide_id)
|
qs = Guide.objects.filter(old_id=old_guide_id)
|
||||||
if not qs.exists():
|
if not qs.exists():
|
||||||
raise serializers.ValidationError({'detail': f'Guide with old id - '
|
raise serializers.ValidationError({'detail': f'Guide with old_id - {old_guide_id}, '
|
||||||
f'{old_guide_id}, '
|
|
||||||
f'is not found.'})
|
f'is not found.'})
|
||||||
return qs.first()
|
return qs.first()
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,21 @@ MEDIA_ROOT = os.path.join(PUBLIC_ROOT, MEDIA_LOCATION)
|
||||||
THUMBNAIL_DEBUG = True
|
THUMBNAIL_DEBUG = True
|
||||||
|
|
||||||
# ADDED TRANSFER APP
|
# ADDED TRANSFER APP
|
||||||
# INSTALLED_APPS.append('transfer.apps.TransferConfig')
|
INSTALLED_APPS.append('transfer.apps.TransferConfig')
|
||||||
|
|
||||||
# DATABASES
|
# DATABASES
|
||||||
DATABASES.update({
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.contrib.gis.db.backends.postgis',
|
||||||
|
'NAME': os.environ.get('DB_NAME'),
|
||||||
|
'USER': os.environ.get('DB_USERNAME'),
|
||||||
|
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||||
|
'HOST': os.environ.get('DB_HOSTNAME'),
|
||||||
|
'PORT': os.environ.get('DB_PORT'),
|
||||||
|
'OPTIONS': {
|
||||||
|
'options': '-c search_path=gm'
|
||||||
|
},
|
||||||
|
},
|
||||||
'legacy': {
|
'legacy': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
# 'HOST': '172.22.0.1',
|
# 'HOST': '172.22.0.1',
|
||||||
|
|
@ -41,7 +52,9 @@ DATABASES.update({
|
||||||
'PORT': 3306,
|
'PORT': 3306,
|
||||||
'NAME': 'dev',
|
'NAME': 'dev',
|
||||||
'USER': 'dev',
|
'USER': 'dev',
|
||||||
'PASSWORD': 'octosecret123'}})
|
'PASSWORD': 'octosecret123'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# LOGGING
|
# LOGGING
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user