a
    ei"                     @   s(  d dl mZ d dlmZmZmZ d dlT ddlT d dlm	Z	 d dl
m
Z
 d dlmZ d dl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 dlZ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dS )    )serializers)ServiceContentManagementSkill)*   )FortunetellerRatingReviews)datetime)	timesinceNc                   @   s   e Zd ZG dd dZdS )ServiceSerializerc                   @   s   e Zd ZeZdZdS )zServiceSerializer.Meta__all__N)__name__
__module____qualname__r   modelfields r   r   :/var/www/html/Ryun_Seer/seer/fortune_teller/serializers.pyMeta   s   r   Nr   r   r   r   r   r   r   r   r   
   s   r   c                   @   s   e Zd ZG dd dZdS )SkillSerializerc                   @   s   e Zd ZeZdZdS )zSkillSerializer.Metar   N)r   r   r   r   r   r   r   r   r   r   r      s   r   Nr   r   r   r   r   r      s   r   c                   @   s2   e Zd Ze Ze Ze Ze	 Z
G dd dZdS )FortuneSignSerializerc                   @   s   e Zd ZeZg dZdS )zFortuneSignSerializer.Meta)	horoscopechinese_zodiacfive_elementmbtiN)r   r   r   FortuneTellerSignDetailr   r   r   r   r   r   r      s   r   N)r   r   r   HoroscopeSerializerr   ChineseZodiacSerializerr   FiveElementsSerializerr   MBTISerializerr   r   r   r   r   r   r      s
   r   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 )FortuneTellerSerializerzfortune_signs.first)sourceget_chat_priceget_video_priceget_is_favouritec                   @   s   e Zd ZeZg dZdS )zFortuneTellerSerializer.Meta)id
first_name	last_nameemailgenderservicesskillsdate_of_birthphone_number	fcm_tokendevice_typetotal_experience	languagesbiobank_detailstimezoneimagenotification_statusis_profile_completedis_stripe_account_connectis_stripe_verifiedratingreferal_codevideo_price
chat_priceis_favourite	is_onlinefortune_signsN)r   r   r   FortuneTellerr   r   r   r   r   r   r   (   s   r   c                 C   s"   |j }|rdd |dD S g S )Nc                 S   s   g | ]}|  qS r   strip).0servicer   r   r   
<listcomp>1       z8FortuneTellerSerializer.get_services.<locals>.<listcomp>,)r+   split)selfobjZservices_stringr   r   r   get_services.   s    z$FortuneTellerSerializer.get_servicesc                 C   s"   |j }|rdd |dD S g S )Nc                 S   s   g | ]}|  qS r   rC   )rE   Zskillr   r   r   rG   7   rH   z6FortuneTellerSerializer.get_skills.<locals>.<listcomp>rI   )r,   rJ   )rK   rL   Zskills_stringr   r   r   
get_skills4   s    z"FortuneTellerSerializer.get_skillsc                 C   s"   |j }|rdd |dD S g S )Nc                 S   s   g | ]}|  qS r   rC   )rE   languager   r   r   rG   =   rH   z9FortuneTellerSerializer.get_languages.<locals>.<listcomp>rI   )r2   rJ   )rK   rL   languages_stringr   r   r   get_languages:   s    z%FortuneTellerSerializer.get_languagesc                 C   s~   t jj|d }|rv|j}t|}t }|	 }g d}|| }|D ]&}	|	d |krJ|	d rl|	d }
qJd}
qJ|
S dS d S )Nfortune_tellerMondayTuesday	WednesdayThursdayFridaySaturdaySundayday	is_activer=   N/A
FortuneTellerTimingobjectsfilterfirstslotsjsonloadsr	   nowweekdayrK   rL   Zfortune_time_slots
slots_datatimedatacurrent_timerh   Zweekday_namesZweekday_namedataZ
price_datar   r   r   r$   @   s    

z'FortuneTellerSerializer.get_video_pricec                 C   s~   t jj|d }|rv|j}t|}t }|	 }g d}|| }|D ]&}	|	d |krJ|	d rl|	d }
qJd}
qJ|
S dS d S )NrR   rT   r\   r]   r>   r^   r_   ri   r   r   r   r#   S   s    

z&FortuneTellerSerializer.get_chat_pricec                 C   s2   | j d}tjj||d }|r*d}nd}|S )N	seer_user)fortunern   TF)contextgetFavouriteUnfavouriteFortunera   rb   rc   )rK   rL   
login_userZfortune_favouriter?   r   r   r   r%   f   s    z(FortuneTellerSerializer.get_is_favouriteN)r   r   r   r   rA   r   SerializerMethodFieldr+   r,   r2   r>   r=   r?   r   rM   rN   rQ   r$   r#   r%   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 )FortuneNotificationSerializerc                 C   s   t |jd S )Nz ago)r
   
created_at)rK   rL   r   r   r   get_created_at_agot   s    z0FortuneNotificationSerializer.get_created_at_agoc                   @   s   e Zd ZeZg dZdS )z"FortuneNotificationSerializer.Meta)r&   messagenotification_typeis_read
updated_atcreated_at_agoN)r   r   r   FortuneTellerNotificationsr   r   r   r   r   r   r   w   s   r   N)r   r   r   r   rt   r|   rw   r   r   r   r   r   ru   q   s   ru   c                   @   s*   e Zd Ze ZG dd dZdd ZdS )FortuneTimingSerializerc                   @   s   e Zd ZeZg dZdS )zFortuneTimingSerializer.Meta)rd   rv   r{   N)r   r   r   r`   r   r   r   r   r   r   r      s   r   c                 C   s   |j }t|}|S )N)rd   re   rf   )rK   rL   rj   ZjsonDatar   r   r   	get_slots   s    
z!FortuneTimingSerializer.get_slotsN)r   r   r   r   rt   rd   r   r   r   r   r   r   r~   }   s   r~   c                       s   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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 fddZ  ZS ) AppointmentRequestListSerializerseer_user.first_nameTr"   	read_onlyseer_user.last_namezseer_user.idzseer_user.professionzseer_user.primary_imagezseer_user.statezseer_user.cityzseer_user.date_of_birthc                   @   s   e Zd ZeZg dZdS )z%AppointmentRequestListSerializer.Meta)r&   appointment_idpriceappointment_dateappointment_timerv   user_idr'   r(   
professionprimary_imagestatecityr-   service_typetwilio_channel_sidtwilio_room_nameappointment_statusN)r   r   r   FortuneAppointmentBookr   r   r   r   r   r   r      s   r   c                    s   t t| |}t|jj}t|jj}|d }|d }|d\}}t	|
 d}	t	|
 d}
t	|d}|j|	j|	jd}|j|
j|
jd}||}||}||}||}|d}||d< |dd |d |d< |S )Nr   r   -z%I:%M %pz%d %B %Y)hourminute)superr   to_representationpytzr5   rn   rS   rJ   r	   strptimerD   replacer   r   localize
astimezonestrftime)rK   instancerm   user_timezonefortune_timezoneZappointment_date_strZappointment_time_rangeZstart_time_strZend_time_str
start_timeend_timer   Zstart_datetimeZend_datetimeZstart_time_user_timezoneZend_time_user_timezoneZstart_time_fortuneZend_time_fortuneZformatted_date	__class__r   r   r      s&    




z2AppointmentRequestListSerializer.to_representation)r   r   r   r   	CharFieldr'   r(   r   r   r   r   r   r-   r   r   __classcell__r   r   r   r   r      s   r   c                   @   s   e Zd ZG dd dZdS )ForutuneTellerWalletSerializerc                   @   s   e Zd ZeZdZdS )z#ForutuneTellerWalletSerializer.Metar   N)r   r   r   FotuneTellerWalletr   r   r   r   r   r   r      s   r   Nr   r   r   r   r   r      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 )	WalletTranscationSerializerr   Tr   r   fortune_teller.first_namec                   @   s   e Zd ZeZg dZdS )z WalletTranscationSerializer.Meta)	r&   transcation_idamountuser_first_namerv   user_last_namefortune_first_namefortune_last_nametranscation_typeN)r   r   r   FortuneTellerTranscationsr   r   r   r   r   r   r      s   r   N)
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s
   r   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 )PayoutTranscationSerializerr   Tr   c                   @   s   e Zd ZeZg dZdS )z PayoutTranscationSerializer.Meta)r&   r   r   rv   r   r   transcation_statusN)r   r   r   FortunePayoutTranscationr   r   r   r   r   r   r      s   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r      s   r   )rest_frameworkr   admin_panel.modelsr   r   r   admin_panel.serializersmodelsfortune_teller.modelsr   r	   django.utils.timesincer
   re   ModelSerializerr   r   r   r!   ru   r~   r   r   r   r   r   r   r   r   r   <module>   s&   
R7
