from django.contrib.gis.db import models as gis_models
from django.db import models


class PlacementPoint(models.Model):
    location_id = models.IntegerField(null=False, blank=False,unique=True)
    address = models.TextField(null=True, blank=True, verbose_name='Адрес')
    name = models.TextField(null=True, blank=True, verbose_name='Название')
    category = models.TextField(null=True, blank=True, verbose_name='Категория')
    status = models.TextField(null=True, blank=True, verbose_name='Статус')
    start_date = models.DateTimeField(null=True, blank=True)
    age_day = models.IntegerField(null=True, blank=True, verbose_name='Возраст')
    prediction_first = models.IntegerField(null=True, blank=True, verbose_name='Прогноз начальный')
    prediction_current = models.IntegerField(null=True, blank=True, verbose_name='Прогноз текущий')
    plan_first = models.IntegerField(null=True, blank=True, verbose_name='Плановый показатель начальный')
    plan_current = models.IntegerField(null=True, blank=True, verbose_name='Плановый показатель текущий')
    fact = models.IntegerField(null=True, blank=True, verbose_name='Фактический показатель')
    delta_first = models.IntegerField(null=True, blank=True, verbose_name='Разница начальная')
    delta_current = models.IntegerField(null=True, blank=True, verbose_name='Разница текущая')
    sample_trn = models.BooleanField(null=True, blank=True)
    flat_cnt = models.IntegerField(null=True, blank=True, verbose_name='Количество квартир')
    year_bld = models.IntegerField(null=True, blank=True, verbose_name='Год постройки')
    levels = models.IntegerField(null=True, blank=True)
    enrg_cls = models.TextField(null=True, blank=True)
    mat_nes = models.TextField(null=True, blank=True)
    doors = models.IntegerField(null=True, blank=True)
    flats_cnt = models.IntegerField(null=True, blank=True)
    popul_home = models.IntegerField(null=True, blank=True)
    popul_job = models.IntegerField(null=True, blank=True)
    other_post_cnt = models.IntegerField(null=True, blank=True)
    target_post_cnt = models.IntegerField(null=True, blank=True)
    yndxfood_cnt = models.IntegerField(null=True, blank=True)
    yndxfood_sum = models.IntegerField(null=True, blank=True)
    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='Координаты')


class AO(models.Model):
    name = models.TextField(null=True, blank=True, verbose_name='Округ')
    polygon = gis_models.MultiPolygonField(null=True,srid=4326)

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)
