o
    g5                    @   sX  d dl Z d dlmZ d dlZd dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZmZmZmZmZ d dlmZ d dlmZmZmZ d d	lmZ d
dlmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- d dlm.Z.m/Z/m0Z0m1Z1 d dl2m3Z3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z: dmddZ;G dd dej<Z=G dd deZ>G dd dej<Z?G dd dej<Z@G dd deZAG dd dej<ZBG d d! d!eZCG d"d# d#ej<ZDG d$d% d%ej<ZEG d&d' d'ej<ZFG d(d) d)ej<ZGG d*d+ d+ej<ZHG d,d- d-ej<ZIG d.d/ d/ej<ZJG d0d1 d1ej<ZKG d2d3 d3ej<ZLG d4d5 d5ej<ZMG d6d7 d7ej<ZNG d8d9 d9ej<ZOG d:d; d;ej<ZPG d<d= d=ej<ZQG d>d? d?ej<ZRG d@dA dAej<ZSG dBdC dCej<ZTG dDdE dEej<ZUG dFdG dGej<ZVG dHdI dIeZWG dJdK dKej<ZXG dLdM dMej<ZYG dNdO dOej<ZZG dPdQ dQej<Z[G dRdS dSej<Z\G dTdU dUej<Z]G dVdW dWej<Z^G dXdY dYej<Z_G dZd[ d[eZ`G d\d] d]eZaG d^d_ d_ej<ZbG d`da daeZcG dbdc dcej<ZdG ddde deej<ZeG dfdg dgejfZgG dhdi diejfZhG djdk dkej<ZiejjeidlZkdS )n    N)ceil)DjangoObjectType)SystemRandom)flat_bedroom_type)CityCountryDemographicPriceGrowthPublicFacilityType)
PageDetail)LanguageSettingTranslateSiteSettings)Prefetch   )
AttachmentCurrencyDevelopmentDevelopmentPublicFacilityDevelopmentTranslateFaqCategoryFaqCategoryTranslateFaqTranslateFeatureFilterSeoTextFlatFlatPriceHistoryFlatTranslateONHAreaONHDistrictONHPostcode
ONHStationONHZonePaymentOptionPaymentPlan)QMinMaxAvg)urlparseparse_qs)cachewraps)BeautifulSoup  c                    s    fdd}|S )Nc                    s   t   fdd}|S )Nc                    sR    j  dtt|  }t|}|d u r' | |fi |}t|| |S )N_)__name__hash	frozensetitemsr+   getset)rootinfokwargs	cache_keyresult)functimeout 3/var/www/Entralon-Web-Backend/development/schema.pywrapper   s   
z3cached_resolver.<locals>.decorator.<locals>.wrapperr,   )r<   r@   r=   )r<   r?   	decorator   s   
z"cached_resolver.<locals>.decoratorr>   )r=   rB   r>   rA   r?   cached_resolver   s   rC   c                   @   sp   e Zd ZdZe Ze Ze Ze Z	e Z
e Ze Ze Ze Ze Ze Ze ZdS )MetaTagsTypezSEO Meta Tags SchemaN)r1   
__module____qualname____doc__grapheneStringtitledescriptionkeywordsog_titleog_descriptionog_imageog_typetwitter_cardtwitter_titletwitter_descriptiontwitter_imagecanonical_urlr>   r>   r>   r?   rD   %   s    rD   c                   @   s*   e Zd Ze ZG dd dZdd ZdS )CurrencyTypec                   @      e Zd ZeZg dZdS )zCurrencyType.Meta)idnamecodedemonymmajor_singlemajor_pluraliso_numsymbolsymbol_nativeminor_singleminor_plural
iso_digitsdecimal_digitsnum_to_basicgbp_rateN)r1   rE   rF   r   modelfieldsr>   r>   r>   r?   Meta8       ri   c                 C   s.   z| j jtjjddd jW S    Y d S )NGBPrZ   )from_currency)to_currencyfilterr   objectsr5   firstrateselfr8   r>   r>   r?   resolve_gbp_rate>   s    zCurrencyType.resolve_gbp_rateN)r1   rE   rF   rH   Floatrf   ri   ru   r>   r>   r>   r?   rV   5   s    rV   c                   @       e Zd ZeeZeeZ	dS )FilterCurrencyTypeN)
r1   rE   rF   rH   ListrV   nodeFieldr   	page_infor>   r>   r>   r?   rx   E       
rx   c                   @   $   e Zd Ze Ze Ze ZdS )AutoScoreNodeN)	r1   rE   rF   rH   rI   rY   iconrv   rankr>   r>   r>   r?   r   J       r   c                   @   s:   e Zd Ze Ze ZG dd dZdd Zdd Z	dS )AttachmentTypec                   @   rW   )zAttachmentType.Meta)rX   fileimagerJ   alttypecategoryN)r1   rE   rF   r   rg   rh   r>   r>   r>   r?   ri   T   rj   ri   c                 C      |   S N)get_type_displayr7   r8   r>   r>   r?   resolve_typeX      zAttachmentType.resolve_typec                 C   r   r   )get_category_displayr   r>   r>   r?   resolve_category[   r   zAttachmentType.resolve_categoryN)
r1   rE   rF   rH   rI   r   r   ri   r   r   r>   r>   r>   r?   r   P   s    r   c                   @      e Zd Ze Ze ZdS )CoordinatesTypeN)r1   rE   rF   rH   rv   latlonr>   r>   r>   r?   r   _       r   c                   @   s|   e Zd Ze Ze Ze Ze Z	e Z
eeZG dd dZdd Zdd Zdd Zd	d
 Zdd Zdd ZdS )DevelopmentPublicFacilityTypec                   @   rW   )z"DevelopmentPublicFacilityType.Meta)	rX   distancedurationduration_walkduration_carr   rY   r   coordinatesN)r1   rE   rF   r   rg   rh   r>   r>   r>   r?   ri   l   rj   ri   c                 C      z| j jW S    Y dS N )public_facilityrY   rs   r>   r>   r?   resolve_nameq      
z*DevelopmentPublicFacilityType.resolve_namec                 C   sH  d}| j }|jjdv rd}n|jjdv rd}n}|jjdv r d}nt|jjdv r)d	}nk|jjd
v r2d}nb|jjdv r;d}nY|jjdv rDd}nP|jjdv rMd}nG|jjdv rVd}n>|jjdv r_d}n5|jjdv rhd}n,|jjdv rqd}n#|jjdv rzd}n|jjdv rd}n|jjdv rd}n|jjd v rd!}z	| | j j W S    Y dS )"Nr   )zsubway-stationsztrain-stationszbus-stationsstation-)schoolszschool-)airportszairport-)restaurantszrestaurant-)	hospitalsz	hospital-)bankszbank-)cinemaszcinema-)marketssupermarketszmarket-)cafeszcafe-)barszbar-)mallszmall-)parkszpark-)theatersztheater-)
pharmaciesz	pharmacy-)parkingr   )gymr   )r   r   slug)rt   r8   prefixpfr>   r>   r?   resolve_slugw   sL   z*DevelopmentPublicFacilityType.resolve_slugc                 C   s&   zt | jjj| jjjW S    Y d S r   )r   r   r   yxrs   r>   r>   r?   resolve_coordinates   s   z1DevelopmentPublicFacilityType.resolve_coordinatesc                 C   s   z| j jjW S    Y dS r   )r   r   rY   rs   r>   r>   r?   r         z*DevelopmentPublicFacilityType.resolve_typec                 C   s6   z| j jdkrt| jW S t| jd W S    Y d S N   g     @"@r   type_idintr   rs   r>   r>   r?   resolve_duration_car      (z2DevelopmentPublicFacilityType.resolve_duration_carc                 C   s6   z| j jdkrt| jW S t| jd W S    Y d S r   r   rs   r>   r>   r?   resolve_duration_walk   r   z3DevelopmentPublicFacilityType.resolve_duration_walkN)r1   rE   rF   rH   rI   rY   r   r   Intr   r   r{   r   r   ri   r   r   r   r   r   r   r>   r>   r>   r?   r   d   s    
(r   c                   @   s&   e Zd Ze Ze ZeeZ	dS )PFTypeN)
r1   rE   rF   rH   rI   r   r   ry   r   listr>   r>   r>   r?   r      s    r   c                   @   sD   e Zd Ze Ze Ze Ze Zdd Z	dd Z
dd ZdS )KeyFeaturesTypec                 C   .   z| j jj| jd jW S    | j j Y S Nlanguage)feature
translatesro   r   rq   r   rs   r>   r>   r?   r      s   zKeyFeaturesType.resolve_slugc                 C   r   r   )r   r   ro   r   rq   rY   rs   r>   r>   r?   r      s   zKeyFeaturesType.resolve_namec                 C      | j jS r   )r   r   rs   r>   r>   r?   resolve_icon   r   zKeyFeaturesType.resolve_iconN)r1   rE   rF   rH   rI   rY   r   valuer   r   r   r   r>   r>   r>   r?   r      s    r   c                   @   r   )AreaNodeNr1   rE   rF   rH   rI   rY   r   r>   r>   r>   r?   r      r   r   c                   @   s4   e Zd Ze Ze Ze Z	e Z
e ZdS )PriceGrowthTypeN)r1   rE   rF   rH   rI   postcodeDatedaterv   priceprice_changechange_percentr>   r>   r>   r?   r      s    r   c                   @   r   )SocialGradeTypeNr1   rE   rF   rH   rI   rY   r   r>   r>   r>   r?   r      r   r   c                   @   r   )AgeTypeNr   r>   r>   r>   r?   r      r   r   c                   @   r   )CommuteMethodTypeNr   r>   r>   r>   r?   r      r   r   c                   @   sR   e Zd Ze Ze Ze Ze	e
Ze	eZe Ze Ze	eZdS )DemographicTypeN)r1   rE   rF   rH   rI   r   rv   deprivationhealthry   r   social_grader   ageproportion_with_degreevehicles_per_householdr   commute_methodr>   r>   r>   r?   r      s    

r   c                   @   r   )PriceHistoryTypeN)r1   rE   rF   rH   rv   timer   r>   r>   r>   r?   r      r   r   c                   @   sF   e Zd Ze Ze Ze Ze Z	e Z
e ZeeZdS )	FlatsTypeN)r1   rE   rF   rH   rI   rY   Booleanis_sold_outareaprice_per_meter
base_pricebedrooms_numry   r   price_historyr>   r>   r>   r?   r     s    r   c                   @   r   )CountryTypeNr   r>   r>   r>   r?   r     r   r   c                   @   r   )CityTypeNr   r>   r>   r>   r?   r     r   r   c                   @   r~   )PaymentOptionTypeN)	r1   rE   rF   rH   rI   rY   r   r   activer>   r>   r>   r?   r     r   r   c                   @   r~   )PaymentPlanTypeN)	r1   rE   rF   rH   rI   rY   r   rv   percentr>   r>   r>   r?   r     r   r   c                   @   r   )BuildingTypeTypeNr   r>   r>   r>   r?   r   !  r   r   c                   @   $   e Zd Ze Ze Zdd ZdS )DevelopmentTypec                 C      d| j  S N	property-r   rs   r>   r>   r?   r   *     zDevelopmentType.resolve_slugN)r1   rE   rF   rH   rI   rJ   r   r   r>   r>   r>   r?   r   &      r   c                   @   r   )DeveloperTypec                 C   r   )Nz
developer-r   rs   r>   r>   r?   r   2  r   zDeveloperType.resolve_slugN)r1   rE   rF   rH   rI   rY   r   r   r>   r>   r>   r?   r   .  r   r   c                   @   s$   e Zd Ze Ze Ze ZdS )MapDeveloperNodeN)r1   rE   rF   rH   rI   rY   r   r   r>   r>   r>   r?   r   6  r   r   c                   @   s<   e Zd Ze Ze Ze Ze Z	e Z
e ZdS )MapFlatsTypeN)r1   rE   rF   rH   rI   rY   r   r   r   r   r   r   r>   r>   r>   r?   r   <  s    r   c                   @      e Zd ZG dd dZdS )MapDevelopmentTypec                   @   s   e Zd ZeZdgZdS )zMapDevelopmentType.Metageo_jsonN)r1   rE   rF   r   rg   rh   r>   r>   r>   r?   ri   G  s    
ri   Nr1   rE   rF   ri   r>   r>   r>   r?   r  E  s    r  c                   @   sX   e Zd Ze Ze Ze Ze Ze Z	ej
ddZdd Zdd Zdd Zd	S )
StationNodeF)default_valuec                 C   s   d|  d S )Nr   r   r5   rs   r>   r>   r?   r   T  s   zStationNode.resolve_slugc                 C   s   z|  dW S    Y d S )Nr   r  rs   r>   r>   r?   r   W  r   zStationNode.resolve_iconc                 C   s    z	d|  d W S    Y d S )Ncity-
city__slugr  rs   r>   r>   r?   resolve_city]  s   zStationNode.resolve_cityN)r1   rE   rF   rH   rI   rY   r   citydistrictr   r   is_selectedr   r   r
  r>   r>   r>   r?   r  L  s    r  c                   @   r   )	PriceTypeN)r1   rE   rF   rH   rv   minmaxr>   r>   r>   r?   r  d  r   r  c                   @   r   )DistrictNodeNr   r>   r>   r>   r?   r  i  r   r  c                   @   r   )FAQTypeN)r1   rE   rF   rH   rI   questionanswerr>   r>   r>   r?   r  n  r   r  c                   @   s   e Zd Ze ZeeZdS )FAQCategoryTypeN)	r1   rE   rF   rH   rI   rJ   ry   r  faqsr>   r>   r>   r?   r  s  s    r  c                   @   r   )BedroomTypeN)r1   rE   rF   rH   rI   r   rY   r>   r>   r>   r?   r  x  r   r  c                   @   r   )CompletionDateNodeNr   r>   r>   r>   r?   r  }  r   r  c                   @   r   )DeveloperTranslateTypeNr   r>   r>   r>   r?   r    r   r  c                   @   s  e Zd Ze Ze Ze Ze Ze Z	e Z
e Ze Ze Ze Ze Ze ZeeZG dd dZdd Zdd Zdd Zdd	 Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Z dd Z!dd Z"dd Zdd  Z#d!d" Z$d#S )$DevelopmentCardTypec                   @   rW   )zDevelopmentCardType.Meta)rX   reference_idrJ   r   r   min_areamax_areaaddressr   currencyr   r   	min_price	max_priceis_ready_to_movestationNr1   rE   rF   r   rg   rh   r>   r>   r>   r?   ri     rj   ri   c                 C   r   r   developmentrX   rs   r>   r>   r?   
resolve_id  r   zDevelopmentCardType.resolve_idc                 C   
   | j jjS r   )r&  	developerrY   rs   r>   r>   r?   r'       
c                 C   r   r   r&  r  rs   r>   r>   r?   resolve_reference_id  r   z(DevelopmentCardType.resolve_reference_idc                 C      d| j j S r   r&  r   rs   r>   r>   r?   r        z DevelopmentCardType.resolve_slugc                 C   r   r   r&  rJ   rs   r>   r>   r?   resolve_title  r   z!DevelopmentCardType.resolve_titlec                 C      | j j jdd dkS Nr   r   r&  flatsallexcludecountrs   r>   r>   r?   resolve_is_sold_out     z'DevelopmentCardType.resolve_is_sold_outc                 C      z| j jdW S    Y dS N,.0f0r&  r   rs   r>   r>   r?   resolve_area     z DevelopmentCardType.resolve_areac                 C   r<  r=  r&  r  rs   r>   r>   r?   resolve_min_area  rB  z$DevelopmentCardType.resolve_min_areac                 C   r<  r=  r&  r  rs   r>   r>   r?   resolve_max_area  rB  z$DevelopmentCardType.resolve_max_areac                 C   "   z| j jj}W |S    d}Y |S N   £r&  default_currencyr_   rt   r8   sr>   r>   r?   resolve_currency     z$DevelopmentCardType.resolve_currencyc                 C   6   z| j j jddtdd dW S    Y dS Nr   r4  r   base_price__minr>  r?  r&  r6  r7  r8  	aggregater&   rs   r>   r>   r?   resolve_min_price  r   z%DevelopmentCardType.resolve_min_pricec                 C   rP  Nr   r4  r   base_price__maxr>  r?  r&  r6  r7  r8  rT  r'   rs   r>   r>   r?   resolve_max_price  r   z%DevelopmentCardType.resolve_max_pricec                    B   g } j j D ]}||j q|  d fdd|D S )N,c                    2   g | ]}|d kr|dk r|nt | jjd qS r   '  langr   r   rZ   .0itemrt   r>   r?   
<listcomp>     2 z<DevelopmentCardType.resolve_bedrooms_num.<locals>.<listcomp>r&  r6  r7  appendr   sortjoinrt   r8   numflatr>   re  r?   resolve_bedrooms_num  
   z(DevelopmentCardType.resolve_bedrooms_numc                 C   r   r   r&  r"  rs   r>   r>   r?   resolve_is_ready_to_move  r   z,DevelopmentCardType.resolve_is_ready_to_movec                 C   r   r   r&  r   rs   r>   r>   r?   r:    r   c                 C   r   r   r&  r   rs   r>   r>   r?   resolve_image  r   z!DevelopmentCardType.resolve_imagec                 C   0   t jj| jdddddddd d S N)developmentsrY   r   r   r	     r!   rp   ro   r&  valuesorder_bydistinctrs   r>   r>   r?   resolve_station     0z#DevelopmentCardType.resolve_stationN)%r1   rE   rF   rH   rI   r   r)  r  r   r  r   r   r"  r   r  r!  r  r   ry   r  r#  ri   r'  r,  r   r1  r:  rA  rD  rF  rN  rU  rY  ro  rr  ru  r~  r>   r>   r>   r?   r    s@    
r  c                   @   s`  e Zd Ze ZeeZe Z	e Z
e ZeeZe Ze Ze Ze Ze Ze Ze Ze Ze Ze Ze ZeeZe Ze Z e Z!ee"Z#eje$e e dZ%ee&Z'ee(Z)ee*Z+e Z,ee-Z.ee/Z0ee1Z2ee3Z4ee5Z6ee7Z8ee9Z:ee;Z<ee=Z>ee=Z?ee=Z@eeAZBeeCZDeeEZFeG ZHeeIZJeeKZLeeKZMeeKZNeeOZPG dd dZQdd ZRdd ZSdd	 ZTd
d ZUdd ZVdfddZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd  Z_d!d" Z`d#d$ Zad%d& Zbd'd( Zcd)d* Zdd+d, Zed-d. Zfd/d0 Zgd1d2 Zhd3d4 Zid5d6 Zjd7d8 Zkd9d: Zld;d< Zmd=d> Znd?d Z\d@dA ZodBdC ZpdDdE ZqdFdG ZrdHdI ZsdJdK ZtdLdM ZudNdO ZvdPdQ ZwdRdS ZxdTdU ZydVdW ZzdXdY Z{dZd[ Z|d\d] Z}d^d_ Z~d`da Zdbdc Zddde ZdS )gDevelopmentTranslateType)includer8  c                   @   rW   )zDevelopmentTranslateType.Meta)0rX   r  rJ   r   r   r  r  r  neighborhoodflooris_featuredis_highlighted
created_atr   r  r   completed_datecompleted_atcompleted_statuscompletion_dater   image_hqr   r!  summaryrK   features_descriptionr"  rr   r)  location
attachmentr   key_featuresr6  r  payment_optionspayment_planspostcode_growth_price	auto_rankpostcode_demographictrain_stationbus_stationr#  similar_developmentspublic_facility_typeprice_numberr  Nr$  r>   r>   r>   r?   ri     rj   ri   c                 C   r   r   r%  rs   r>   r>   r?   r'  %  r   z#DevelopmentTranslateType.resolve_idc                 C   r   r   r+  rs   r>   r>   r?   r,  (  r   z-DevelopmentTranslateType.resolve_reference_idc                 C   r-  r   r.  rs   r>   r>   r?   r   +  r/  z%DevelopmentTranslateType.resolve_slugc                 C   r   r   r0  rs   r>   r>   r?   r1  .  r   z&DevelopmentTranslateType.resolve_titlec                 C   s   z9| j r| j d d  t| j dkrd W S d W S | jr7| jd d  t| jdkr2d W S d W S dW S    Y dS )N  ...r     )r  lenrK   rs   r>   r>   r?   resolve_summary1  s   0<z(DevelopmentTranslateType.resolve_summaryNc                 C   s<   | j j }|r|j|ddS |r|j|ddS |S )Nr[  category__in)r&  attachmentsr7  ro   splitr8  )rt   r8   r  r8  r  r>   r>   r?   resolve_attachment9  s   z+DevelopmentTranslateType.resolve_attachmentc                 C   s   | j j S r   )r&  public_facilitiesr7  rs   r>   r>   r?   resolve_public_facilityB  r   z0DevelopmentTranslateType.resolve_public_facilityc                 C   sH   g }t j D ]}| jjj|d}| r!|t|j	|j
|d q|S )N)public_facility__type)r   r   r   )r
   rp   r7  r&  r  ro   existsri  r   rY   r   )rt   r8   outpf_typer   r>   r>   r?   resolve_public_facility_typeE  s   	
z5DevelopmentTranslateType.resolve_public_facility_typec                 C   s.   zt | jjj| jjjW S    t dd Y S )NgI@gʦ)r   r&  r   r   r   rs   r>   r>   r?   resolve_locationW  s   z)DevelopmentTranslateType.resolve_locationc                 C   s<   | j j  }z|jd|j dW S    d d d Y S )N	district-rY   r   )r&  onh_districtr7  rq   rY   r   )rt   r8   r  r>   r>   r?   resolve_district]  s
   z)DevelopmentTranslateType.resolve_districtc                 C   r2  r3  r5  rs   r>   r>   r?   r:  d  r;  z,DevelopmentTranslateType.resolve_is_sold_outc                 C   sL   z| j j jtddd d W d S    t }|dd }|  Y S )Nrr   )rate_avgr  r>  ry     )r&  development_reviewsr7  rT  r(   r   	randrange)rt   r8   
crypto_genrr   r>   r>   r?   resolve_rateg  s   &
z%DevelopmentTranslateType.resolve_ratec                 C   s*   | j jrddddd}|| jj S | j jS )NReady To Move   آماده سکونت   جاهزة للسكن"   Готовая к переездуenfaarru)r&  r"  r   rZ   r  )rt   r8   r   r>   r>   r?   resolve_completion_dateo  s   z0DevelopmentTranslateType.resolve_completion_datec                 C   r   r   )r&  r  rs   r>   r>   r?   resolve_completed_at{  r   z-DevelopmentTranslateType.resolve_completed_atc                 C   sl   ddddd}| j jrd}|| jj }n| j jd ur)d| j jd }| j j}nd}|| jj }||d	S )
Nr  r  r  r  r  zcompletion-ready-to-movecompletion-z%Yr  )r&  r"  r   rZ   r  strftimer  )rt   r8   r   r   rY   r>   r>   r?   resolve_completed_date~  s   

z/DevelopmentTranslateType.resolve_completed_datec                 C   r<  r=  r@  rs   r>   r>   r?   rA    rB  z%DevelopmentTranslateType.resolve_areac                 C   r<  r=  rC  rs   r>   r>   r?   rD    rB  z)DevelopmentTranslateType.resolve_min_areac                 C   r<  r=  rE  rs   r>   r>   r?   rF    rB  z)DevelopmentTranslateType.resolve_max_areac                 C   r<  r=  )r&  r  rs   r>   r>   r?   resolve_floor  rB  z&DevelopmentTranslateType.resolve_floorc                 C   rG  rH  rJ  rL  r>   r>   r?   rN    rO  z)DevelopmentTranslateType.resolve_currencyc                 C   rP  rQ  rS  rs   r>   r>   r?   rU    r   z*DevelopmentTranslateType.resolve_min_pricec                 C   rP  rV  rX  rs   r>   r>   r?   rY    r   z*DevelopmentTranslateType.resolve_max_pricec                 C   s8   | j j jddtdtd}t|d |d dS )Nr   r4  r   rR  rW  )r  r  )r&  r6  r7  r8  rT  r'   r&   r  )rt   r8   pr>   r>   r?   resolve_price_number  s   z-DevelopmentTranslateType.resolve_price_numberc                    rZ  )Nr[  c                    r\  r]  ra  rb  re  r>   r?   rf    rg  zADevelopmentTranslateType.resolve_bedrooms_num.<locals>.<listcomp>rh  rl  r>   re  r?   ro    rp  z-DevelopmentTranslateType.resolve_bedrooms_numc                    s<   g } j j D ]}||j q|   fdd|D S )Nc                    s>   g | ]}d | |dkr|dk r|nt | jjd dqS )bedroom-r   r^  r_  )r   rY   ra  rb  re  r>   r?   rf    s   > z=DevelopmentTranslateType.resolve_bedrooms.<locals>.<listcomp>)r&  r6  r7  ri  r   rj  rl  r>   re  r?   resolve_bedrooms  s
   z)DevelopmentTranslateType.resolve_bedroomsc                 C   r   r   )r&  r  rs   r>   r>   r?   resolve_completed_status  r   z1DevelopmentTranslateType.resolve_completed_statusc                 C   r   r   )r&  r  rs   r>   r>   r?   resolve_is_featured  r   z,DevelopmentTranslateType.resolve_is_featuredc                 C   r   r   )r&  r  rs   r>   r>   r?   resolve_is_highlighted  r   z/DevelopmentTranslateType.resolve_is_highlightedc                 C   r   r   rq  rs   r>   r>   r?   rr    r   z1DevelopmentTranslateType.resolve_is_ready_to_movec                 C   r   r   rs  rs   r>   r>   r?   r:    r   c              	   C   sP   z| j j jddgdd }|jW S    z| j jW  Y S    Y Y dS )Nr   r   )type__in?r   )r&  r  r7  ro   r|  rq   r   )rt   r8   r  r>   r>   r?   resolve_image_hq  s   
z)DevelopmentTranslateType.resolve_image_hqc                 C   r   r   rt  rs   r>   r>   r?   ru    r   z&DevelopmentTranslateType.resolve_imagec                 C   s   | j jdd S )Nr   feature__translates)r&  r  select_relatedprefetch_relatedr7  rs   r>   r>   r?   resolve_key_features  s   z-DevelopmentTranslateType.resolve_key_featuresc                 C   s  g }| j j }tt d }|D ]}|j }g }z|jj| jd	 j
}W n   t|j| jjd}Y d }	|D ]+}
|
j}	tj|
jd }t|j|j|jdddd }|t|d |
jd q:|	d urr|||	d d|j  k r}dk rn n|jnt|j| jjd}d }d }|jd ur|jdkr|jd}|jd ur|jdkr|jd}|t||j|jd|||| q|S )N  r   r_  r   )r   r   r^  r>  )r&  r6  r7  r   r   r   r   ro   r   rq   rY   r   r   rZ   r   datetimefromtimestampyearmonthday	timestampri  r   r   r   r   r   )rt   r8   r  r6  nowrn  phsph_arY   l_pricephp_timerm  p_p_mb_pr>   r>   r?   resolve_flats  sN   

"


$z&DevelopmentTranslateType.resolve_flatsc                 C   L   z| j j}|jj| jd }|d u r|}|jd|j dW S    Y d S Nr   r  r  r&  r  r   ro   r   rq   rY   r   rt   r8   r  ctr>   r>   r?   r
       z%DevelopmentTranslateType.resolve_cityc                 C   sp   g }t j }|D ],}z|jj| jd j}W n   |j}Y || jj	 v }|
t|d|j | q	|S )Nr   pay_opt-)r#   rp   r7  r   ro   r   rq   rY   r&  payment_optionri  r   r   )rt   r8   r  r  porY   r   r>   r>   r?   resolve_payment_options#  s   
z0DevelopmentTranslateType.resolve_payment_optionsc                 C   sh   g }t jj| jd}|D ]%}z|jj| jd j}W n   |j}Y |t	|d|j
 |j q|S )N)r&  r   	pay_plan-)r$   rp   ro   r&  r   r   rq   rJ   ri  r   r   r   )rt   r8   r  r  r  rJ   r>   r>   r?   resolve_payment_plans0  s"   z.DevelopmentTranslateType.resolve_payment_plansc                 C   sZ   g }| j j }|D ] }z|jj| jd j}W n   |j}Y |t	||j
 q
|S r   )r&  building_typer7  r   ro   r   rq   rY   ri  r   r   )rt   r8   r  r  r  rY   r>   r>   r?   resolve_building_types>  s   z/DevelopmentTranslateType.resolve_building_typesc              	   C   sn   g }z| j jj}|dd }W n   d }Y tjj| j j|d}|D ]}|t	||j
|j|j|j q#|S )N r   countryr   )r&  r  zip_coder  r	   rp   ro   r  ri  r   r   r   r   r   )rt   r8   r  r  r   pgspgr>   r>   r?   resolve_postcode_growth_priceJ  s   
z6DevelopmentTranslateType.resolve_postcode_growth_pricec              	   C   s@  z| j jj}|dd }W n   d }Y ztjj| j j|d}|j}g }|D ]}|	t
|||  q(|j}d}	z
|	t|d 7 }	W n   Y z
|	t|d 7 }	W n   Y z
|	t|d 7 }	W n   Y d}
z
|
t|d 7 }
W n   Y z
|
t|d 7 }
W n   Y d}z
|t|d	 7 }W n   Y z
|t|d
 7 }W n   Y z
|t|d 7 }W n   Y z
|t|d 7 }W n   Y d}z
|t|d 7 }W n   Y z
|t|d 7 }W n   Y z
|t|d 7 }W n   Y z
|t|d 7 }W n   Y d}z
|t|d 7 }W n   Y z
|t|d 7 }W n   Y z
|t|d 7 }W n   Y z
|t|d 7 }W n   Y z
|t|d 7 }W n   Y d|	ddd|
ddd|ddd|ddd|ddg}|j}g }|D ]}|	t|dd||  qwt|j|j|j|||j|j|W S    Y d S )Nr  r   r  z0-4z5-9z10-14z15-19z20-24z25-29z30-34z35-39z40-44z45-49z50-54z55-59z60-64z65-69z70-74z80-84z85-89z0-14z,.2f)rY   r   z15-24z24-44z45-64z65+r0   )r&  r  r  r  r   rp   r5   r  r   ri  r   r   floatr   r   replacer   r   r   r   r   r   )rt   r8   r  r   r  r   sgkr   age_14age_24age_44age_64age_65agr   cmr>   r>   r?   resolve_postcode_demographicX  s   
 "z5DevelopmentTranslateType.resolve_postcode_demographicc                 C   sF   t jddddddj| jj| jj| jdj	| j
d d d	 S )
Nr&  development__citydevelopment__countrydevelopment__default_currencydevelopment__flatsdevelopment__attachments)development__developerr  r   )rX   r   )r   rp   r  r  ro   r&  r)  r  r   r8  rX   r}  rs   r>   r>   r?   resolve_similar_developments  s&   
z5DevelopmentTranslateType.resolve_similar_developmentsc                 C   rv  rw  rz  rs   r>   r>   r?   r~    r  z(DevelopmentTranslateType.resolve_stationc                 C   sD   g }| j j }|D ]}|jj }|jj}||||jd q
|S )N)rY   r   r   )r&  auto_scoresr7  elementr   rY   ri  r   )rt   r8   r  ranksr   r   rY   r>   r>   r?   resolve_auto_rank  s   
z*DevelopmentTranslateType.resolve_auto_rankc                 C   sr   t | jd d d }| j|d| j d| j | j|d| jj dd| j|d| jj d| jj d	| j	 d
S )Nzhtml.parseri,  znew homes, new building, , https://file.entralon.com/websiter  https://entralon.com/
/property-rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   )
r.   rK   get_textrJ   rL   r&  r   r   rZ   r   )rt   r8   rK   r>   r>   r?   resolve_meta_tags  s$   
z*DevelopmentTranslateType.resolve_meta_tagsc                 C   s   dd| j d| jj d| j d| jj | j| j d| jj d| j d| jj	j
 d| jj  | j dd	| j d
| j| jj	j
| jj	j
| jjj
 d| jjj ddd| jjj | jjj dddd| jj | j ddS )Nhttps://schema.orgRealEstateListingr  r  r  zHome > z > zReal EstatePlacePostalAddressr   )@typerY   )r  streetAddressaddressLocalityaddressRegion
postalCodeaddressCountryGeoCoordinates)r  latitude	longitude)r  rY   r  geoImageObject)r  urlcaption)@contextr  rY   r'  r   rK   
datePostedmainEntityOfPage
breadcrumblastReviewed	specialtyaboutprimaryImageOfPage)rJ   r   rZ   r   r&  r   rK   r  	isoformatr  rY   
updated_atr  onh_postcoder  r   r   r   rs   r>   r>   r?   resolve_micro_data  s@   



z+DevelopmentTranslateType.resolve_micro_datac                 C   s   z[t jddj| jj| jd }| s&t jddj| jjdd }g }|D ].}t	jddj|j|j
| jd}| sOt	jddj|j
| jdd}||j|d	 q*|W S    Y d S )
Nr   r   )category__faqs__development_idr   r  )r5  language__codefaq)r   faq__categoryfaq__development)r8  r9  r6  )rJ   r  )r   rp   r  ro   r&  rX   r   r}  r  r   r   ri  rJ   )rt   r8   r   r  catr  r>   r>   r?   resolve_faq4  sR   

z$DevelopmentTranslateType.resolve_faqc                 C   J   zt jjd| j| jd}t|dkrt jjd| jdd}|W S    Y d S )NzProperty Detailsfaq__category__titler9  r   r   r  r>  r9  r6  r   rp   ro   r&  r   r  rt   r8   r  r>   r>   r?   resolve_faq_property_detailS     
z4DevelopmentTranslateType.resolve_faq_property_detailc                 C   r<  )NPricesr=  r   r  r?  r@  rA  r>   r>   r?   resolve_faq_prices^  rC  z+DevelopmentTranslateType.resolve_faq_pricesc                 C   r<  )N	Amenitiesr=  r   r  r?  r@  rA  r>   r>   r?   resolve_faq_amenitiesi  rC  z.DevelopmentTranslateType.resolve_faq_amenities)NN)r1   rE   rF   rH   rI   r   ry   r  bedroomsr  r   r!  r{   r  r  r  r  r   r  r  r"  r   r   r  r  rr   r   r  r  r  r   r  r  r   r   r  r   r  r   r   r   r  r   r  r  r   r6  r   r  r   r  r   r  r   building_typesr   r  r   r  r  r  r  r  r  r#  r   r  r  r  rD   	meta_tags
JSONString
micro_datar  r7  r  faq_property_detail
faq_pricesfaq_amenitiesr  r)  ri   r'  r,  r   r1  r  r  r  r  r  r  r:  r  r  r  r  rA  rD  rF  r  rN  rU  rY  r  ro  r  r  r  r  rr  r  ru  r  r  r
  r  r  r  r  r  r  r~  r  r  r4  r;  rB  rE  rG  r>   r>   r>   r?   r    s    

























	
	$
 	(r  c                   @   sB   e Zd ZeeZeeZ	e
 ZeeZe Ze ZdS )FilterDevelopmentTypeN)r1   rE   rF   rH   ry   r  rz   r{   r   r|   r   
filter_numrD   rJ  rK  rL  rI   seo_textr>   r>   r>   r?   rP  u  s    


rP  c                   @   r  )FlatPriceHistoryTypec                   @   s   e Zd ZeZddgZdS )zFlatPriceHistoryType.Metar   r  N)r1   rE   rF   r   rg   rh   r>   r>   r>   r?   ri     rj   ri   Nr  r>   r>   r>   r?   rS  ~  s    rS  c                   @   s   e Zd Ze ZeeZee	Z
e ZeeZe Ze Ze Ze Ze Ze Ze Ze Ze Ze Zdd Zdd Zdd Zdd Zd	d
 Z dd Z!dd Z"dd Z#dd Z$dd Z%dd Z&dd Z'dd Z(dS )FlatTypec                 C   r   r   )rn  r&  rs   r>   r>   r?   resolve_development  r   zFlatType.resolve_developmentc                 C   r(  r   )rn  r&  r)  rs   r>   r>   r?   resolve_developer  r*  zFlatType.resolve_developerc                 C   s@   t jj| jj| jd }|d u rt jj| jjdd }|jS )Nr&  r   r  r&  r6  )r   rp   ro   rn  r&  r   rq   r  rt   r8   devr>   r>   r?   resolve_address  s   
zFlatType.resolve_addressc                 C   r  r  r  r  r>   r>   r?   r
    r  zFlatType.resolve_cityc                 C   s   z;t jj| jj| jd }|d u rt jj| jjdd }|jr9|jd d  t|jdkr4d W S d W S dW S    Y dS )NrW  r  rX  r  r  r  r   )	r   rp   ro   rn  r&  r   rq   r  r  rY  r>   r>   r?   r    s   
<zFlatType.resolve_summaryc                 C   s   | j }|jdk r|jnd|j }|jjjdd }|jjjg dd }|jj  }|dkrE||d kr:d}|jjjdd| }n-|dkr^||d krQd}|jjjg dd| }n|dkrr||d krjd}|jj | }z|jW S    Y d	S )
Nr  i'     )r   )r\  r      r      r  r   r   r   )rn  r   r&  r  ro   r9  r7  r   )rt   r8   rn  img_idcc1c2r  r>   r>   r?   ru    s>   zFlatType.resolve_imagec                 C   r   r   )rn  r   rs   r>   r>   r?   ro    r   zFlatType.resolve_bedrooms_numc                 C   r   r   )rn  bathrooms_numrs   r>   r>   r?   resolve_bathrooms_num  r   zFlatType.resolve_bathrooms_numc                 C   r   r   )rn  r  rs   r>   r>   r?   r    r   zFlatType.resolve_is_featuredc                 C   r   r   )rn  r   rs   r>   r>   r?   r:    r   zFlatType.resolve_is_sold_outc                 C   r   r   )rn  r   rs   r>   r>   r?   rA    r   zFlatType.resolve_areac                 C   r   r   )rn  r   rs   r>   r>   r?   resolve_price_per_meter  r   z FlatType.resolve_price_per_meterc                 C   r   r   )rn  r   rs   r>   r>   r?   resolve_base_price  r   zFlatType.resolve_base_priceN))r1   rE   rF   rH   rI   rY   r{   r   r&  r   r)  r  r   r  r  r   IDrX   r   r   rc  r   r  r   rv   r   r   r   rU  rV  r[  r
  r  ru  ro  rd  r  r:  rA  re  rf  r>   r>   r>   r?   rT    s:    



rT  c                   @   rw   )FilterFlatTypeN)
r1   rE   rF   rH   ry   rT  rz   r{   r   r|   r>   r>   r>   r?   rh    r}   rh  c                   @   s(   e Zd ZdZdZdZdZdZdZdZ	dS )	DevelopmentSortdevelopment__titlez-development__titler  z-created_atdevelopment__base_pricez-development__base_pricer  N)
r1   rE   rF   NAME_ASC	NAME_DESCCREATED_AT_ASCCREATED_AT_DESC	PRISE_ASC
PRISE_DESCRANDOMr>   r>   r>   r?   ri    s    ri  c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )FlatSortflat__bedrooms_numz-flat__bedrooms_num
flat__areaz-flat__areaflat__created_atz-flat__created_atflat__base_pricez-flat__base_pricer  N)r1   rE   rF   BEDROOM_ASCBEDROOM_DESCAREA_ASC	AREA_DESCrn  ro  rp  rq  rr  r>   r>   r>   r?   rs    s    rs  c                   @   s|  e Zd Zejee e e e dZeje	fi de
 de de de de
 de
 de
 d	e d
eejde de deejdeejdeejdeejdeejdeejdeejdeejdeejdeejde
 deejdeejdeejde
 deejde de de Zejefi de
 de de de de
 de
 de
 d	e d
eejde de deejdeejdeejdeejdeejdeejdeejdeejdeejdeejdeejdeejdeejde
 deejde de de Zejeejd d!e d"Zd3d'd(Zd d#d$ejd%d&d)fd*d+Zd d#d$ejd,d&d fd-d.Zed/d0d4d1d2Zd%S )5Query)page	page_sizesearchr   limitr}  r~  r  featured	availableready_to_mover  r  sort_byr   r)  r  payment_planr  key_featurebedroombathroomlondon_zip_codelondon_arealondon_zonern  r  	post_coderegionall_filtersr#  	price_min	price_maxr  T)required)r   r   r   
   Nr  c           	   	   C   s   |dkrd}d|d |  }|| }t j }|r4|dkr4|t|dt|dB t|dB t|dB }||| || k |dk||| t| | d	d
S )N   r   r   r   name__icontains)code__icontains)symbol__icontains)symbol_native__icontainshas_next_pagehas_previous_pagecurrent_pager~  r9  pages_count)rz   r|   )r   rp   r7  ro   r%   r9  r   )	rt   r8   r}  r~  r  r   startendqsr>   r>   r?   resolve_currencies  s(   


zQuery.resolve_currenciesFc	           N         s  |dkrd}d}
t jj|d   d u rt jjdd  tj }z
tjj| d}W n   tjj|dd}Y tdd dd	}|jpFd
}|j	pKd
}d}d j
 }d
}d }d }d }d }d }d|	v rm|t|	d dM }d|	v r|	d}|dd}|jpd
}|d| 7 }|d| 7 }d| }d  } } } } }}|}|d urit|dkri|d u rt|dt|dB t|dB t|dB }n|t|dt|dB t|dB t|dB O }|d u rt|dt|dB }n|t|dt|dB O }|d u r	t|dt|dB }n|t|dt|dB O }|d u r%t|dt|dB }n|t|dt|dB O }|d u rAt|dt|dB }n|t|dt|dB O }|d u r]t|dt|dB }n|t|dt|dB O }|d urtj| }|d u rt|d}n|t|dO }|d urtj| } |d u rt| d}n|t| dO }|d urtj| }!|d u rt|!d}n|t|!dO }|d urtj| }"|d u rt|"d}n|t|"dO }|d urtj| }#|d u rt|#d }n|t|#d O }|d ur||M }d!|	v rC|	d! rC|
d7 }
|	d!dk}$|d"7 }|d#7 }|d$7 }||d
kr6d%nd
 d&7 }|t|$d'M }d(|	v rw|	d( rw|
d7 }
|	d(}%|d)7 }|d*7 }|d+7 }||d
krjd%nd
 d,7 }|t|%d-M }d }&d }'d.|	v r|	d.r|	d.}(|(d/d
})|)|	d.< |d0|) 7 }|d1|) 7 }|d|) 7 }|d2|) 7 }tjj|)d3}&|& dkrd }&n
|& }&|&j}*|*j}'|t|)d4M }t|)d5}d6|	v rH|	d6rH|
d7 }
|	d6}+d7d8 |+D },|,|	d6< |d9d|, d:7 }|d;d|, d:7 }|dd|, 7 }t|+dkr.|d<|+d  7 }d6}|,d }n||d
kr6d%nd
 d=d>|+ 7 }|t|,d?M }d@|	v r|	d@r|
d7 }
|	d@}-dAd8 |-D }.|d0d|. dB7 }|d1d|. dB7 }|dd|. 7 }t|-dkr|d<|-d  7 }|d u rd@}|.d }n||d
krd%nd
 dCd>|- 7 }|t|.dDM }dE|	v r-|	dEr-|
d7 }
|	dE }/dFd8 |/D }0|0|	dE< |d0d|0 dG7 }|d1d|0 dG7 }|dd|0 7 }t|/dkr|d<|/d  7 }|d u rdH}|0d }n||d
krd%nd
 dId>|/ 7 }|t|0dJM }dK|	v r|	dKr|
d7 }
|	dK}1dLd8 |1D }2|dMd|2 dN7 }|dOd|2 dP7 }|dd|2 7 }t|1dkr|d<|1d  7 }|d u rdQ}|2d }n||d
krd%nd
 dRd>|1 7 }|t|2dSM }dT|	v r|	dTr|
d7 }
|	dT}3dUd8 |3D }4|d0d|4 7 }|d1d|4 7 }|dd|4 7 }t|3dkr|d<|3d  7 }|d u rdV}|4d }n||d
krd%nd
 dWd>|3 7 }|t|4dXM }dY|	v ru|	dYru|
d7 }
|	dY}5|d0d|5 7 }|d1d|5 7 }|dd|5 7 }t|5dkr[|d<|5d  7 }|d u rZdZ}|5d }n||d
krcd%nd
 d[d>|5 7 }|t|5d\M }d]|	v r|	d]r|
d7 }
|	d]}6d^d8 |6D }7|dMd fd_d8|7D  7 }|dOd fd`d8|7D  7 }|dd fdad8|7D  7 }t|6dkr|d<|6d  7 }|d u rd]}|7d }n||d
krd%nd
 dbd>|6 7 }|t|7dcM }dd|	v r_|	ddr_|
d7 }
|	dd}8ded8 |8D }9|dMd|9 df7 }|dOd|9 df7 }|dd|9 7 }t|8dkrE|d<|8d  7 }n||d
krMd%nd
 dgd>|8 7 }|t|9dhM }di|	v r|	dir|
d7 }
|	di}:djd8 |:D };|dkd|; 7 }|dld|; 7 }|dd|; 7 }||d
krd%nd
 dmd>|; 7 }dn|;v r|;dn |tdd-t|;doB M }n|t|;doM }dp|	v r|	dpr|
d7 }
|	dp}<|dq|<dr|'rd|'j nd
 7 }|ds|<dr7 }|dt|<dr7 }||d
krd%nd
 du|<dr7 }|tddvt|<dw@ M }dx|	v rk|	dxrk|	dx}=|dy|=dr|'r9d|'j nd
 7 }|dz|=dr7 }|d{|=dr7 }||d
krVd%nd
 d||=dr7 }|tddvt|=d}@ M }tjd~dddddddddddddddddddddd| }>|r|>dd|j }>n|>d|j }>|> }?|rt!|?| }@||@kr|@}|dk rd}d|d |  }A|A| }B|B|?k }Cnd}@||@kr|@}|dk rd}d}A|?}Bd}C|dkr||d
krd%nd
 d| 7 }|d| 7 }|d| 7 }|d
krd| }||7 }g }D|>|A|B D ];}E|D"d|Ej#d j
 d|Ej$j% |Ej$j& d|Ej$j' |Ej(d|Ej$j& d|Ej$j)rGdn|Ej$j*|Ej$jj
dddd qdd|Dd}Fd|j+ }Gd }H|rm|}Intd d}Id }J|rzG|d6krtjj|d3j,}Jn7|d@krtjj|d3j,}Jn)|dHkrtjj|d3j,}Jn|dVkrtjj|d3j,}Jn|dZkrtjj|d3j,}JW n   d }Jd }Y |It|Jdt|d@ M }Id }K|rz|d]kr|}Kn|dQkrt-jj|d3j,}KW n   d }Kd }Y |It|Kdt|d@ M }It.j|I }Ld }M|Ld u 	s|Lj/0  dk	r*t.jjd d d d d d }L|L	rD|Lj/j d }M|Md u 	rD|Lj/jdd }M|M	rJ|Mj1}H|>|A|B |C|dk|||?|@d|H|
|&||||||Gdd|||G|d|FdS )N2   r   rl   r  )site_settingsr   )r  r6  TF)development__is_activedevelopment__is_deletedr   !development__developer__is_activer   znew homes, new buildingr  r  development__is_featuredr  +r  z search for r  zsearch=r   )development__title__icontains))development__translates__title__icontains)development__slug__icontains)(development__translates__slug__icontains)slug__icontainsr  )development__onh_station__in)development__onh_district__in)development__onh_postcode__in)development__onh_zone__in)development__onh_area__inr  z available homeszlist of available homesz, available homes&zavailable=truedevelopment__is_sold_outr  z ready to move homeszlist of ready to move homesz, ready to move homeszreadyToMove=truedevelopment__is_ready_to_mover  r  z in zlist of new building in z/city-r   development__city__slug)r	  r#  c                 S      g | ]	}| d ddqS r   r   r   r  rb  r>   r>   r?   rf        z.Query.resolve_developments.<locals>.<listcomp>z around of z stationzlist of new building around of /zstation=r[  "development__onh_station__slug__inr  c                 S   r  r  r   r   r  rb  r>   r>   r?   rf        z	 districtz	district=#development__onh_district__slug__inr  c                 S   r  zzipcode-r   r   r  rb  r>   r>   r?   rf    r  z zipcoder   zlondonZipCode=#development__onh_postcode__slug__inr  c                 S   r  zkey_feature-r   r   r  rb  r>   r>   r?   rf    r  z with z featurezlist of new building with z	 featuresr   zkeyFeature=,development__key_features__feature__slug__inr  c                 S   r  zarea-r   r   r  rb  r>   r>   r?   rf    r  r   zlondonArea=)development__onh_area__slug__inr  zonezlondonZone=)development__onh_zone__slug__inr  c                 S   r  r  r   r   r  rb  r>   r>   r?   rf    r  c                       g | ]}t | jqS r>   r   rZ   rc  r   r_  r>   r?   rf        c                    r  r>   r  r  r_  r>   r?   rf    r  c                    r  r>   r  r  r_  r>   r?   rf    r  zbedroom=)$development__flats__bedrooms_num__inr  c                 S      g | ]}| d dqS r  r   r  rb  r>   r>   r?   rf  )      z payment optionzpaymentOption=%development__payment_option__slug__inr  c                 S   r  )r  r   r  rb  r>   r>   r?   rf  6  s
    z complete in z!list of new building complete in zcompletionDate=ready-to-move#development__completed_at__year__inr  z more than z.0fzlist of new building more than z, more than z	priceMin=)"development__flats__base_price__gt)#development__flats__base_price__gter  z less than zlist of new building less than z, less than z	priceMax=)#development__flats__base_price__lterX   rJ   r   r  rk  r  r   r)  r&  r  r  r  r
  r  r	  development__public_facilities/development__public_facilities__public_facility5development__public_facilities__public_facility__typedevelopment__key_features"development__key_features__featuredevelopment__payment_optiondevelopment__payment_planr  development__completed_atzpage=z | Page r  ListItemr  r  r  Offerzsold outzhttps://schema.org/InStock)r  r   priceCurrencyavailability)r  rY   offers)r  positionr'  rY   r   rK   rd  r  ItemList)r)  r  itemListElement)r  )first_filter)first_filter_type)second_filter)second_filter_type)r  r  r  r  r  r   )r6  r  r  r  )rz   r|   rR  rQ  r  rJ  rL  )2r   rp   ro   rq   r   r   r5   r%   development_list_titledevelopment_list_descriptionrZ   r  development_search_titler  r!   r}  r   r    r"   r   r   r9  r  rK  rk  remover_   r   onlyr  r  r|  r   r   ri  rX   r&  r   rJ   r   r  r   r   default_development_imagerY   r   r   r   r7  text)Nr7   r8   r  r}  r~  r  r  r   rn  r9   rQ  setting	setting_tfrJ   rK   rL   rU   qr  r  r  r  filter_cityr  rM  	station_s
district_slondon_zone_slondon_area_slondon_zip_code_s	s_station
s_districts_london_zip_codes_zones_arear   r  r  rK  city_k	city_slugr  	station_kr#  
district_kr  	zipcode_kzipcodekey_features_kr  london_area_kr  r  
bedrooms_krH  payment_options_kr  completion_date_kr  
price_fromprice_tor  r9  r  r  r  r  	item_listrd  rL  r   rR  fstf_names_namefilter_seo_text
seo_text_tr>   r_  r?   resolve_developments,  s  





























&

&
&

&

&

&
"""
&
&
&


$"

$"
	






 












zQuery.resolve_developmentsrk   c	           )      K   sR  |dkrd}d}
t jj|d }|d u rt jjdd }z	tjj|d}W n   tjjdd}Y d }tddd}d	|	v rH|t|	d	 d
M }d|	v r{|	dr{|	d}|dd}||	d< tjj|d}|	 dkrpd }n| }|t|dM }d|	v r|	dr|
d7 }
|	d}dd |D }|t|dM }d|	v r|	dr|
d7 }
|	d}dd |D }|t|dM }d|	v r|	dr|
d7 }
|	d}|t|dM }d|	v r|	dr|
d7 }
|	d}dd |D }|t|dM }d|	v r|	dr|
d7 }
|	d}dd |D }|t|dM }d |	v r6|	d r6|
d7 }
|	d }|tdd!t|d"@ M }d#|	v rR|	d#rR|	d#}|tdd!t|d$@ M }d%|	v rt|	d%rt|
d7 }
|	d%}d&d |D }|t|d'M }d(|	v r|	d(r|
d7 }
|	d(}|t|d)M }d*|	v r|	d*r|
d7 }
|	d*}d+d |D }|t|d,M }d-|	v r|	d-r|
d7 }
|	d- }d.d |D }||	d-< |t|d/M }d0|	v r|	d0r|
d7 }
|	d0}d1d |D }d2|v r|
d2 |tdd3t|d4B M }n|t|d4M }d5|	v r*|	d5r*|
d7 }
|	d5}|t|d6M }d7|	v rE|	d7rE|
d7 }
|	d7}|t|d8M }d9|	v rk|	d9rk|
d7 }
|	d9}d:d |D }||	d9< |t|d;M }d<|	v r|	d< r|
d7 }
|	d<dk}|t|d=M }d>|	v r|	d> r|
d7 }
|	d>} |t| d3M }tj|}!tjd?d@dAdBdCdDdEj|!|dFdG|j }"|"	 }#|rt|#| }$||$kr|$}|dk rd}d|d |  }%|%| }&|&|#k }'nd}$||$kr|$}|dk rd}d}%|#}&d}'i }(|"|%|& |(dH< |'|dk|||#|$dI|(dJ< |j|(dC< |
|(dK< ||(d< |(S )LNr  r   rl   r  rk   TF)r  r  r  r  r  r  r   r   r   r  r  c                 S   r  r  r  rb  r>   r>   r?   rf    r  z'Query.resolve_flats.<locals>.<listcomp>r  r  c                 S   r  )r  r   r  rb  r>   r>   r?   rf    r  )#development__payment_plan__slug__inr  )$development__building_type__slug__inr  c                 S   r  r  r  rb  r>   r>   r?   rf  (  r  r  r  c                 S   r  r  r  rb  r>   r>   r?   rf  .  r  )bedrooms_num__inr  )base_price__gt)base_price__gter  )base_price__lter  c                 S   r  r  r  rb  r>   r>   r?   rf  ;  r  r  r  ),development__location__london_zone__slug__inr  c                 S   r  r  r  rb  r>   r>   r?   rf  D  r  ),development__location__london_area__slug__inr  c                 S   r  r  r  rb  r>   r>   r?   rf  J  r  r  r  c                 S   r  )r  r   r   r  rb  r>   r>   r?   rf  P  s
    r  r  r  r  ).development__location__post_code__out_code__inr  )2development__location__post_code__region__slug__inr#  c                 S   r  r  r  rb  r>   r>   r?   rf  c  r  r  r  r  r  rn  flat__developmentflat__development__cityflat__development__countryr   flat__price_historyflat__development__attachments)flat__inr   flat__is_sold_outrz   r  r|   rQ  )r   rp   ro   rq   r   r5   r%   r  r   r9  r  r   r   r  r  r|  r   r}  r   rZ   ))r7   r8   r  r}  r~  r  r  r   r  r9   rQ  r`  rK  r  r  r  r  r  rI  r  rH  r  r  r  r  r  r  r  r  r  r#  r   r  r6  r  r9  r  r  r  r  resultsr>   r>   r?   r    sL  

















	






zQuery.resolve_flatsr/   rA   c                 C   s   t jj|d }|dd}|d u rt jjdd }tjddddd	d
dddddddddddddddddddjt|dt|dB d d!d |d" }|d u r~tjddddd
dddddddddddddddjt|dt|dB d d!dd# }|S )$Nrl   r   r   r  r&  r  r  r  r
  r   r  !development__flats__price_historydevelopment__flats__translatesr	  r  r  .development__key_features__feature__translatesr  'development__payment_option__translatesr  %development__payment_plan__translatesdevelopment__building_type&development__building_type__translatesr  r  r  development__onh_stationdevelopment__auto_scores!development__auto_scores__element)development__slug)development__translates__slugTF)r  r  r  r   )r  r  r6  )	r   rp   ro   rq   r  r   r  r  r%   )r7   r8   r   r   r`  r&  r>   r>   r?   rU    s   !"
zQuery.resolve_development)r   r  Nr  )r  )r1   rE   rF   rH   r{   rx   r   rI   
currenciesrP  r   ry   ri  rv   rx  rh  r6  r  r&  r  ro  r  rs  r  rC   rU  r>   r>   r>   r?   r|    s    RR

   Q %r|  )query)r/   )lr  mathr   r   rH   graphene_djangor   randomr   development.utilsr   geo_location.modelsr   r   r   r	   r
   main.graphene_toolsr   main.modelsr   r   r   django.db.modelsr   modelsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   urllib.parser)   r*   django.core.cacher+   	functoolsr-   bs4r.   rC   
ObjectTyperD   rV   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  rP  rS  rT  rh  Enumri  rs  r|  Schemaschemar>   r>   r>   r?   <module>   s    X
T
	d     	d
     i