
    wg                         d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	 d dl
mZmZ  G d dej                  Z G d d	ej                  Z G d
 dej                  ZdS )    )serializers)IdeaLike)	UserOfferUserProduct)ProductsSerializer)DateFieldDot
ImageFieldc                       e Zd Z e            Z ej                    Z e            Z	 ej                    Z
 G d d          Zd Zd ZdS )UserProductsSerializerc                       e Zd ZeZg dZdS )UserProductsSerializer.Meta)
idproductcomment	connectedlinkgainend_promotionredirectionsfully_verified
created_atN)__name__
__module____qualname__r   modelfields     )/var/www/html/cms/web/user/serializers.pyMetar      s$        
 
 
r   r!   c                     t           j                            |j        |j                                                  }|r|j        S dS )N)offer__productuser )r   objectsfilterr   r$   firstr   )selfuser_product
user_offers      r    get_linkzUserProductsSerializer.get_link   sE    &--\=QXdXi-jjpprr
 	#?"rr   c                 *   |j         j                            d                                          }|r|j                            d          S |j         j                                        D ]%}|j        r|j                            d          c S &dS )Nu   Пригласи друга)partner_program%d.%m.%Yu   Бессрочно)r   offersr'   r(   get_end_promotionstrftimeallr   )r)   r*   offers      r    r1   z(UserProductsSerializer.get_end_promotion%   s    $+22C`2aaggii 	@*33J???!)04466 	D 	DE" D.77
CCCCCD $#r   N)r   r   r   r   r   r   SerializerMethodFieldr   r	   r   r   r!   r,   r1   r   r   r    r   r   	   s          ""G5K577MJ,;,..D
 
 
 
 
 
 
 
  
$ 
$ 
$ 
$ 
$r   r   c                      e Zd Z ej                    Z ej                    Z ej                    Z ej                    Z ej                    Z	 e
            Z ej                    Z G d d          Zd Zd Zd Zd Zd Zd Zd	S )
IdeasSerializerc                       e Zd ZeZg dZdS )IdeasSerializer.Meta)r   categorytitledescriptionr   statusfinishe_dater$   user_idlikes_countadmin_answerliked	user_iconN)r   r   r   r   r   r   r   r   r    r!   r9   ;   s$        
 
 
r   r!   c                 @    |j         j        r|j         j        j        S d S N)r$   profile_pictureurlr)   ideas     r    get_user_iconzIdeasSerializer.get_user_iconM   s"    9$ 	19,00tr   c                     | j         d         }|sdS t          j                            ||                                          S )Nr$   F)rI   r$   )contextr   r&   r'   exists)r)   rI   r$   s      r    	get_likedzIdeasSerializer.get_likedS   sB    |F# 	5|""4"88??AAAr   c                     |j         j        S rE   )r$   	full_namerH   s     r    get_userzIdeasSerializer.get_userZ   s    y""r   c                 Z    t          |j                                      |j                  S rE   )dictSTATUSESgetr=   rH   s     r    
get_statuszIdeasSerializer.get_status]   s"    DM""&&t{333r   c                 H    |j         r|j                             d          S dS )Nr/   z---)r>   r2   rH   s     r    get_finishe_datez IdeasSerializer.get_finishe_date`   s)     	:$--j999ur   c                     |j         S rE   )r@   rH   s     r    get_likes_countzIdeasSerializer.get_likes_countf   s    r   N)r   r   r   r   r5   r>   r@   r=   r$   rB   r	   r   rC   r!   rJ   rN   rQ   rV   rX   rZ   r   r   r    r7   r7   2   s       4;466L3+355K.[.00F,;,..D-K-//EJ1133I
 
 
 
 
 
 
 
$  B B B# # #4 4 4           r   r7   c                   F    e Zd Z e            Z ej                    Zd ZdS )UserSerializerc                 "    |j         r|j         S dS )Nr%   )second_name)r)   r$   s     r    get_second_namezUserSerializer.get_second_namen   s     	$##rr   N)	r   r   r   r
   rF   r   r5   r^   r_   r   r   r    r\   r\   j   s>         jllO3+355K    r   r\   N)rest_frameworkr   +infrastructure.persistence.models.user.idear   r   .infrastructure.persistence.models.user.productr   r   web.catalog.serializersr   web.common.serializersr	   r
   ModelSerializerr   r7   r\   r   r   r    <module>rf      s   & & & & & & B B B B B B B B Q Q Q Q Q Q Q Q 6 6 6 6 6 6 ; ; ; ; ; ; ; ;&$ &$ &$ &$ &$[8 &$ &$ &$R5  5  5  5  5 k1 5  5  5 p    [0     r   