
    W8i                     `    d dl mZ d dlmZ d dlmZ  e       Z G d dej                        Zy)    )serializers)Call)get_user_modelc                      e Zd Z ej                  d      Z ej                         Z ej                  d      Z ej                         Z	 ej                  d      Z ej                  d      Z ej                  d      Z ej                         Z ej                         Z ej                         Zd Zd Zd	 Zd
 Z G d d      Zy)CallPhraseReportSerializerpk)sourcetwilio_call_sid
created_atcaller_namefrom_numberc                 "    |j                   xs dS )NUnknown)r   )selfobjs     L/var/www/html/dp2/backend_v2.1/server/apps/calls/serializers/catch_phrase.pyget_customer_phonez-CallPhraseReportSerializer.get_customer_phone   s    +)+    c                     t        |dg       S )N_cached_phrases)getattr)r   calls     r   get_catch_phrases_foundz2CallPhraseReportSerializer.get_catch_phrases_found   s    t.33r   c                 J   |j                   s| j                         S t        j                  j	                  |j                         j                  d      j                         }|rt        |d      s| j                         S |j                  j                  |j                  dS )N)idprofilenamephone)transfer_user_idreturn_emptyUserobjectsfilterselect_relatedfirsthasattrr   	full_nametransfer_number)r   r   users      r   get_advisorz&CallPhraseReportSerializer.get_advisor   s    $$$$&&||""d&;&;"<KKIV\\^743$$&& LL**))
 	
r   c                     d d dS )Nr    )r   s    r   r!   z'CallPhraseReportSerializer.return_empty'   s    t..r   c                       e Zd ZeZg dZy)CallPhraseReportSerializer.Meta)
r   call_idtwilio_call_idsummarycall_date_timecustomer_namecustomer_phone
transcriptcatch_phrases_foundadvisorN)__name__
__module____qualname__r   modelfieldsr-   r   r   Metar/   *   s    
r   r>   N)r9   r:   r;   r   IntegerFieldr   	CharFieldr0   r1   r2   DateTimeFieldr3   r4   r5   r6   SerializerMethodFieldr7   r8   r   r   r+   r!   r>   r-   r   r   r   r      s    	!	!	!	.B#k##%G*[**2CDN#k##%G.[..lCN)K))?M*[**-@N&&&(J;+;;=/k//1G,4
/
 
r   r   N)	rest_frameworkr   apps.calls.modelsr   django.contrib.authr   r"   ModelSerializerr   r-   r   r   <module>rG      s(    & " .0
!<!< 0
r   