a
    =NCe>                     @   sD  d dl mZ d dlT ddlT d dlmZmZmZ d dlT d dl	m
Z
 G dd dejZG dd	 d	ejZG d
d dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG d d! d!ejZd"S )#    )serializers)*   )ContentManagementFaqCompatibilityHoroscope)	timesincec                   @   s2   e Zd Ze Ze Ze Ze	 Z
G dd dZdS )SeerSignSerializerc                   @   s   e Zd ZeZg dZdS )zSeerSignSerializer.Meta)	horoscopechinese_zodiacfive_elementmbtiN)__name__
__module____qualname__SeerUserSignDetailmodelfields r   r   5/var/www/html/Ryun_Seer/seer/seer_user/serializers.pyMeta   s   r   N)r   r   r   HoroscopeSerializerr
   ChineseZodiacSerializerr   FiveElementsSerializerr   MBTISerializerr   r   r   r   r   r   r	   
   s
   r	   c                   @   sT   e Zd ZeddZe Ze Ze Z	G dd dZ
dd Zdd Zd	d
 ZdS )SeerUserSerializerseer_signs.firstsourcec                   @   s   e Zd ZeZg dZdS )zSeerUserSerializer.Meta)id
first_name	last_nameemailgenderdate_of_birthphone_number	fcm_tokendevice_typereligion
professionheightnotification_statuscountry_originstatecity	languageshobbiesbio	educationincomeimagestimezoneis_profile_completedreferal_code
seer_signsNr   r   r   SeerUserr   r   r   r   r   r   r      s   r   c                 C   s,   |j }|r$|dddd}ng }|S Nz[]' z, r/   stripreplacesplitselfobjZlanguages_stringZlanguages_arrayr   r   r   get_languages    s
    z SeerUserSerializer.get_languagesc                 C   s,   |j }|r$|dddd}ng }|S r;   r0   r?   r@   rA   rC   rD   Zhobbies_stringZhobbies_arrayr   r   r   get_hobbies(   s
    zSeerUserSerializer.get_hobbiesc                 C   s,   |j }|r$|dddd}ng }|S r;   r4   r?   r@   rA   rC   rD   Zimages_stringZimages_arrayr   r   r   
get_images0   s
    zSeerUserSerializer.get_imagesN)r   r   r   r	   r8   r   SerializerMethodFieldr/   r0   r4   r   rE   rH   rK   r   r   r   r   r      s   
r   c                   @   s*   e Zd Ze Zdd ZG dd dZdS )UserNotificationSerializerc                 C   s   t |jd S )Nz ago)r   
created_at)rC   rD   r   r   r   get_created_at_ago;   s    z-UserNotificationSerializer.get_created_at_agoc                   @   s   e Zd ZeZg dZdS )zUserNotificationSerializer.Meta)r   messagenotification_typeis_read
updated_atcreated_at_agoN)r   r   r   SeerUserNotificationsr   r   r   r   r   r   r   >   s   r   N)r   r   r   r   rL   rT   rO   r   r   r   r   r   rM   9   s   rM   c                   @   s   e Zd ZG dd dZdS )ServiceSerializerc                   @   s   e Zd ZeZddgZdS )zServiceSerializer.Metar   service_nameN)r   r   r   Servicer   r   r   r   r   r   r   G   s   r   Nr   r   r   r   r   r   r   r   rV   F   s   rV   c                   @   s   e Zd ZG dd dZdS )LanguageSerializerc                   @   s   e Zd ZeZdgZdS )zLanguageSerializer.Metar/   Nr9   r   r   r   r   r   L   s   r   NrY   r   r   r   r   rZ   K   s   rZ   c                   @   s   e Zd ZG dd dZdS )SeerUserWalletSerializerc                   @   s   e Zd ZeZdZdS )zSeerUserWalletSerializer.Meta__all__N)r   r   r   SeerUserWalletr   r   r   r   r   r   r   R   s   r   NrY   r   r   r   r   r[   Q   s   r[   c                   @   sR   e Zd ZejdddZejdddZejdddZejdddZG dd dZ	d	S )
AppointmentFortuneTellerzfortune_teller.first_nameTr   	read_onlyzfortune_teller.last_namezfortune_teller.imagezfortune_teller.servicesc                   @   s   e Zd ZeZg dZdS )zAppointmentFortuneTeller.Meta)r   appointment_idr    r!   fortune_teller_servicesappointment_dateimageappointment_timeserviceservice_typepriceappointment_statustwilio_channel_sidtwilio_room_nameN)r   r   r   FortuneAppointmentBookr   r   r   r   r   r   r   ]   s   r   N)
r   r   r   r   	CharFieldr    r!   rd   rb   r   r   r   r   r   r^   W   s
   r^   c                   @   s   e Zd ZG dd dZdS )SeerUserCardSerializerc                   @   s   e Zd ZeZdZdS )zSeerUserCardSerializer.Metar\   N)r   r   r   SeerUserCardsr   r   r   r   r   r   r   b   s   r   NrY   r   r   r   r   rn   a   s   rn   c                   @   s6   e Zd ZejdddZejdddZG dd dZdS )WalletTranscationSerializerz!booking.fortune_teller.first_nameTr_   z booking.fortune_teller.last_namec                   @   s   e Zd ZeZg dZdS )z WalletTranscationSerializer.Meta)r   transcation_idamountr    rN   r    r!   transcation_typeN)r   r   r   SeerUserTranscationr   r   r   r   r   r   r   l   s   r   N)r   r   r   r   rm   r    r!   r   r   r   r   r   rp   g   s   rp   c                   @   sD   e Zd ZejdddZejdddZejdddZG dd dZdS )	FortunerTellerReviewSerializerzseer_user.primary_imageTr_   zseer_user.first_namezseer_user.last_namec                   @   s   e Zd ZeZg dZdS )z#FortunerTellerReviewSerializer.Meta)	r   	seer_userseer_user_first_nameseer_user_last_namefortune_tellerratingreviewrN   seer_user_imageN)r   r   r   FortunetellerRatingReviewsr   r   r   r   r   r   r   v   s   r   N)	r   r   r   r   rm   r|   rw   rx   r   r   r   r   r   ru   r   s   ru   c                   @   s   e Zd ZeddZe Ze Ze Z	ejddZ
ejddZejdd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 )SeerUserCompatibilitySerializerr   r   get_compatibilityget_login_user_signsget_friend_statusc                   @   s   e Zd ZeZg dZdS )z$SeerUserCompatibilitySerializer.Meta)r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r,   r-   r.   r/   r0   r1   r2   r3   r4   r6   r8   compatibilitylogin_user_signsfriend_statusNr9   r   r   r   r   r      s   r   c                 C   s,   |j }|r$|dddd}ng }|S r;   r>   rB   r   r   r   rE      s
    z-SeerUserCompatibilitySerializer.get_languagesc                 C   s,   |j }|r$|dddd}ng }|S r;   rF   rG   r   r   r   rH      s
    z+SeerUserCompatibilitySerializer.get_hobbiesc                 C   s,   |j }|r$|dddd}ng }|S r;   rI   rJ   r   r   r   rK      s
    z*SeerUserCompatibilitySerializer.get_imagesc                 C   s  | j d}tjj|d }tjj|d }|jj}|jj}|jj	}|j
rX|j
j}nd }|jj}	|j
rt|j
j}
nd }
g }i }|r|
rd}d}d}d}nd}d}d}d}|	d	krtjj||jjd
 }tjj||jjd }tjj||jj	d }tjj||
d }n\tjj|jj|d
 }tjj|jj|d }tjj|jj	|d }tjj|
|d }||j }||j }||j }||r|jd ur|jnd }|| | | }|j|j|j|j|j|j|j|j|j|sd n|j|sd n|j|sd n|j|d}|S )Nseer_user_idrv   g      ?g333333?g?r   g333333?g?Male)male_horoscopefemale_horoscope)male_chinese_zodiacfemale_chinese_zodiac)male_element_namefemale_element_name)male_mbti_namefemale_mbti_name)Zhoroscope_taglinehoroscope_compatibility_scoreZhoroscope_descriptionZchinese_zodiac_tagline"chinese_zodiac_compatibility_scoreZchinese_zodiac_descriptionZfive_elements_tagline!five_elements_compatibility_scoreZfive_elements_descriptionZmbti_taglinembti_compatibility_scoreZmbti_descriptiontotal_weighted_score)contextgetr   objectsfilterfirstr
   r   r   element_namer   	mbti_namerv   r#   r   CompatibilityChineseZodiacCompatibilityFiveElementsCompatibilityMBTIcompatibility_scoretaglinedescription)rC   rD   login_user_id
login_userZmatched_user_signslogin_user_horoscopelogin_user_chinese_zodiaclogin_user_element_namelogin_user_mbti_namelogin_user_genderZmatched_user_mbticompatibility_scorescompatibility_datambti_weighthoroscope_weightchinese_zodiac_weightelement_weighthoroscope_compatibilitychinese_zodiac_compatibilityfive_elements_compatibilitymbti_compatibilityZhoroscope_scoreZzodiac_scoreZelement_scoreZ
mbti_scorer   r   r   r   r      s    












 z1SeerUserCompatibilitySerializer.get_compatibilityc              	   C   s   | j d}tjj|d }|jj}|jj}|jj	}|jj
}|jj
}|jj
}	|jrf|jj}
|jj
}nd }
d }||||||	|
|d}|S )Nr   r   )r
   horoscope_imager   chinese_zodiac_imager   element_imager   
mbti_image)r   r   r   r   r   r   r
   r   r   r   rd   r   r   )rC   rD   r   r   r
   r   r   r   r   r   r   r   Zlogin_user_datar   r   r   r      s.    
z4SeerUserCompatibilitySerializer.get_login_user_signsc                 C   s   | j d}td| tjj|d }tjtj	||dtj	||dB }|sVd }n(|D ]"}|j
dkrnd}qZ|j
dkrZd}qZ|S )	Nr   login_user=========)r   	from_userto_userTfriendsF	requested)r   r   printr:   r   r   r   FriendRequestmodelsQaccepted)rC   rD   r   r   r   r   r   r   r   r     s    


z1SeerUserCompatibilitySerializer.get_friend_statusN)r   r   r   r	   r8   r   rL   r/   r0   r4   r   r   r   r   rE   rH   rK   r   r   r   r   r   r   r   r~   |   s   
Tr~   c                   @   s.   e Zd ZejddZG dd dZdd ZdS )SeerUserFriendSerializerr   r   c                   @   s   e Zd ZeZg dZdS )zSeerUserFriendSerializer.Meta)
r   r    r!   r$   primary_imager)   r-   r.   r,   r   Nr9   r   r   r   r   r   3  s   r   c                 C   sp   | j d}td| tjtj||dtj||dB }|sDd }n(|D ]"}|jdkr\d}qH|jdkrHd}qH|S )Nr   r   r   Tr   Fr   )	r   r   r   r   r   r   r   r   r   )rC   rD   r   r   r   r   r   r   r   8  s    


z*SeerUserFriendSerializer.get_friend_statusN)r   r   r   r   rL   r   r   r   r   r   r   r   r   1  s   r   c                   @   s    e Zd Ze ZG dd dZdS )SentFriendListSerializerc                   @   s   e Zd ZeZg dZdS )zSentFriendListSerializer.Meta)r   r   r   Nr   r   r   r   r   r   r   r   r   r   r   P  s   r   N)r   r   r   r   r   r   r   r   r   r   r   M  s   r   c                   @   s    e Zd Ze ZG dd dZdS )ReceivedFriendListSerializerc                   @   s   e Zd ZeZg dZdS )z!ReceivedFriendListSerializer.Meta)r   r   r   Nr   r   r   r   r   r   X  s   r   N)r   r   r   r   r   r   r   r   r   r   r   U  s   r   N)rest_frameworkr   admin_panel.serializersr   admin_panel.modelsr   r   r   fortune_teller.modelsdjango.utils.timesincer   ModelSerializerr	   r   rM   rV   rZ   r[   r^   rn   rp   ru   r~   r   r   r   r   r   r   r   <module>   s*   
%

 6