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