AlexP077 3 years ago committed by Dmitry Titov
parent 8c286aa2f0
commit 22d5823c0c

@ -9,7 +9,6 @@ https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
from pathlib import Path
@ -87,7 +86,7 @@ DATABASES = {
'PASSWORD': os.getenv('POSTGRES_PASSWORD', 'postgres'),
'HOST': os.getenv('POSTGRES_HOST', 'localhost'),
'PORT': os.getenv('POSTGRES_PORT', 5432),
}
},
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
@ -149,7 +148,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.getenv('EMAIL_HOST', 'smtp.yandex.ru')
EMAIL_PORT = os.getenv('EMAIL_PORT', 587)
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', 'noreply@spatiality.website')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', "spatialitypass321")
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', 'spatialitypass321')
EMAIL_USE_TLS = True
FRONTEND_URL = os.getenv('REACT_APP_DOMAIN_URL', 'http://localhost:3000/')
REST_REGISTRATION = {
@ -162,3 +161,4 @@ REST_REGISTRATION = {
'VERIFICATION_FROM_EMAIL': 'noreply@spatiality.website',
}
SRID = 4326

@ -1,6 +1,7 @@
from django.contrib.gis.db import models as gis_models
from django.db import models
from postamates.settings import SRID
from service.signals import *
@ -42,22 +43,22 @@ class PlacementPoint(models.Model):
yndxfood_cnt_cst = models.IntegerField(null=True, blank=True)
okrug = models.ForeignKey('AO', on_delete=models.CASCADE, null=True, blank=True)
rayon = models.ForeignKey('Rayon', on_delete=models.CASCADE, null=True, blank=True)
geometry = gis_models.PointField(srid=4326, null=True, verbose_name='Координаты')
geometry = gis_models.PointField(srid=SRID, null=True, verbose_name='Координаты')
class AO(models.Model):
name = models.TextField(null=True, blank=True, verbose_name='Округ')
polygon = gis_models.MultiPolygonField(null=True, srid=4326)
polygon = gis_models.MultiPolygonField(null=True, srid=SRID)
class Rayon(models.Model):
name = models.TextField(null=True, blank=True, verbose_name='Район')
AO = models.ForeignKey('AO', related_name='rayons', on_delete=models.CASCADE)
polygon = gis_models.MultiPolygonField(null=True, srid=4326)
polygon = gis_models.MultiPolygonField(null=True, srid=SRID)
class Rivals(models.Model):
WKT = gis_models.PointField(srid=4326, null=True)
WKT = gis_models.PointField(srid=SRID, null=True)
info = models.TextField(null=True, blank=True)
type = models.TextField(null=True, blank=True)
source = models.TextField(null=True, blank=True)

@ -99,190 +99,25 @@ class PlacementPointViewSet(ReadOnlyModelViewSet):
@action(detail=False, methods=['get'])
def filters(self, request):
qs = self.get_queryset()
age_day = [
x for x in list(set(qs.values_list('age_day', flat=True)))
if
x is not None
]
prediction_first = [
x for x in list(
set(qs.values_list('prediction_first', flat=True)),
) if
x is not None
]
prediction_current = [
x for x in list(
set(qs.values_list('prediction_current', flat=True)),
) if
x is not None
]
plan_first = [
x for x in
list(set(qs.values_list('plan_first', flat=True))) if
x is not None
]
plan_current = [
x for x in
list(set(qs.values_list('plan_current', flat=True))) if
x is not None
]
fact = [
x for x in list(set(qs.values_list('fact', flat=True))) if
x is not None
]
delta_first = [
x for x in
list(set(qs.values_list('delta_first', flat=True))) if
x is not None
]
delta_current = [
x for x in
list(set(qs.values_list('delta_current', flat=True)))
if x is not None
]
flat_cnt = [
x for x in list(set(qs.values_list('flat_cnt', flat=True)))
if x is not None
]
year_bld = [
x for x in list(set(qs.values_list('year_bld', flat=True)))
if x is not None
]
levels = [
x for x in list(set(qs.values_list('levels', flat=True))) if
x is not None
]
doors = [
x for x in list(set(qs.values_list('doors', flat=True))) if
x is not None
]
flats_cnt = [
x for x in
list(set(qs.values_list('flats_cnt', flat=True))) if
x is not None
]
popul_home = [
x for x in
list(set(qs.values_list('popul_home', flat=True))) if
x is not None
]
popul_job = [
x for x in
list(set(qs.values_list('popul_job', flat=True))) if
x is not None
]
other_post_cnt = [
x for x in
list(
set(qs.values_list('other_post_cnt', flat=True)),
)
if x is not None
]
target_post_cnt = [
x for x in list(
set(qs.values_list('target_post_cnt', flat=True)),
) if
x is not None
]
yndxfood_cnt = [
x for x in
list(set(qs.values_list('yndxfood_cnt', flat=True))) if
x is not None
]
yndxfood_sum = [
x for x in
list(set(qs.values_list('yndxfood_sum', flat=True))) if
x is not None
]
yndxfood_cnt_cst = [
x for x in list(
set(qs.values_list('yndxfood_cnt_cst', flat=True)),
) if
x is not None
]
keys = (
'age_day', 'prediction_first', 'prediction_current',
'plan_first', 'plan_current', 'fact', 'delta_first',
'delta_current', 'flat_cnt', 'year_bld', 'levels',
'doors', 'flats_cnt', 'popul_home', 'popul_job',
'other_post_cnt', 'target_post_cnt', 'yndxfood_cnt',
'yndxfood_sum', 'yndxfood_cnt_cst',
)
temp_data = {
key: [
x for x in list(set(qs.values_list(key, flat=True))) if
x is not None
]
for key in keys
}
data = {
'age_day': [min(age_day), max(age_day)] if age_day else [0, 2030],
'prediction_first': [
min(prediction_first), max(
prediction_first,
),
] if prediction_first else [-22, 22],
'prediction_current': [
min(prediction_current), max(
prediction_current,
),
] if prediction_current else [
-22,
22,
],
'plan_first': [
min(plan_first),
max(plan_first),
] if plan_first else [0, 100],
'plan_current': [
min(plan_current),
max(plan_current),
] if plan_current else [0, 100],
'fact': [min(fact), max(fact)] if fact else [0, 100],
'delta_first': [
min(delta_first),
max(delta_first),
] if delta_first else [0, 100],
'delta_current': [
min(delta_current),
max(delta_current),
] if delta_current else [
0,
100,
],
'flat_cnt': [min(flat_cnt), max(flat_cnt)] if flat_cnt else [
0,
100,
],
'year_bld': [min(year_bld), max(year_bld)] if year_bld else [
0,
2030,
],
'levels': [min(levels), max(levels)] if levels else [0, 100],
'doors ': [min(doors), max(doors)] if doors else [0, 100],
'flats_cnt': [min(flats_cnt), max(flats_cnt)] if flats_cnt else [
0,
100,
],
'popul_home': [
min(popul_home),
max(popul_home),
] if popul_home else [0, 100],
'popul_job': [min(popul_job), max(popul_job)] if popul_job else [
0,
100,
],
'other_post_cnt': [
min(other_post_cnt),
max(other_post_cnt),
] if other_post_cnt else [
0,
100,
],
'target_post_cnt': [
min(target_post_cnt),
max(target_post_cnt),
] if target_post_cnt else [
0, 100,
],
'yndxfood_cnt': [
min(yndxfood_cnt),
max(yndxfood_cnt),
] if yndxfood_cnt else [0, 100],
'yndxfood_sum': [
min(yndxfood_sum),
max(yndxfood_sum),
] if yndxfood_sum else [0, 100],
'yndxfood_cnt_cst': [
min(yndxfood_cnt_cst), max(
yndxfood_cnt_cst,
),
] if yndxfood_cnt_cst else [0, 100],
key: [
min(temp_data[key]), max(temp_data[key]),
] if temp_data[key] else [0, 100] for key in keys
}
return Response(data, status=status.HTTP_200_OK)

Loading…
Cancel
Save