
    9i                         d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZmZ  G d de	      Z G d	 d
e	      Z G d de	      Z G d de	      Z G d dej"                        Z G d dej&                        Zy)    )models)Company)User)timezone)AbstractTimeStampModel)BotTypeCRON_JOB_STATUSc                      e Zd ZdZg dZed   dfed   dfed   dfed   dfgZddgZg d	Ze	j                  j                  d
fe	j                  j                  dfgZ ej                  ddd      Z ej                  d      Z ej                  d      Z ej&                  ed      Z ej&                  de      Z ej                  ddd      Z ej.                  eej2                  dd      Z ej.                  eej2                  dd      Z ej.                  dddej2                  d      Z ej                  d      Z ej>                  d      Z  ej>                  dd      Z! ej>                  d      Z" ej&                  de      Z# ej&                  d      Z$ ejJ                  dd      Z& ejJ                  dd      Z' ej                  d      Z( ej                  d      Z) ej>                  dd      Z* ejV                  dd      Z, ej&                  de      Z- ej&                  de      Z. ej.                  eej2                  ddd      Z/ ejV                  dd      Z0y )!CallCall object.))r   zNot Transferred)   Transferred)   zTransfer FailedNOT_PROCESSED
PROCESSING	COMPLETEDFAILED)r   zNo Intent for booking)r   zIntent for booking))r   z*Ontime - call received during office hours)r   z*Offtime - call received after office hours)   z&Holiday - call received during holidayz	Sales BotzService Bot   T
max_lengthblanknullr   r   )choicesdefault)r   r   	on_deleter   r   zcompanies.Dealershipcalls)r   r   r   related_namer   r   r   r      r   )
max_digitsdecimal_placesr   r   
read_calls)r   r   r   r    N)1__name__
__module____qualname____doc__TRANSFER_STATUS_CHOICESr	   BOOKING_INTENT_STATUS_CHOICESBOOKING_INTENT_CHOICESCALL_TIME_CATEGORY_CHOICESr   	SALES_BOTvalueSERVICE_BOTBOT_TYPE_CHOICESr   	CharFieldcaller_namefrom_number	to_numberSmallIntegerFieldtransfer_statuscall_time_categorytransfer_number
ForeignKeyr   SET_NULLtransfer_userr   company
dealershipstatus	TextField
transcripttranscript_completesummarybot_type	sentimentDecimalFielddurationcostcall_idtwilio_call_sidtwilio_recording_textDateTimeFieldbooking_datetimebooking_intentbooking_intent_statusread_byread_at     :/var/www/html/dp2/backend_v2.1/server/apps/calls/models.pyr   r   
   s    
	)?;		&5		%{3		"H-	%! 	%!" 
			 	 +.				"	"M2
 #&""cDIK"&""c2K   C0I.f..'O 211tE_`&f&&#TMO%F%%dfooDX\]Mf6??UYZG"""//J V-F!!!-J*&**DAfT*G'v''T;KLH(((d3I"v""aBH6!A>Df#.G&f&&#6O,F,,4dC+v++TB-V--4AWXN4F44$HeffdRVeqrG"f""D9GrV   r   c                   
   e Zd ZdZ ej
                  d      Z ej
                  d      Z ej
                  d      Z ej                  d      Z
 ej                  dd      Z ej
                  d      Z ej
                  d      Z ej                  dd      Z ej                   eej$                  dd      Z ej
                  d      Z ej
                  d      Z ej
                  d      Z G d d	      Zy
)TonyCallr   r   r   Tr!   r'   r   c                       e Zd ZdZy)TonyCall.Metavtony_callsN)r)   r*   r+   db_tablerU   rV   rW   Metar[   \   s     rV   r^   N)r)   r*   r+   r,   r   r5   
end_reasonrL   recording_urlrC   rD   rO   call_date_time	intentionrescheduledrP   r=   r   r>   r@   rB   	called_tocalled_numberr^   rU   rV   rW   rY   rY   M   s    !!!S1Jf#.G$F$$4M!!!-J)V))t4@N   C0I#6##s3K+v++TBf6??UYZGV-F   C0I$F$$4M! !rV   rY   c                   $   e Zd ZddgZ ej
                  eej                  d      Z ej
                  e	ej                  d      Z
 ej                  de      Z ej                  d	      Z ej                  d
ddd      Z G d d      Zd Zy)CallActivity)READread)PLAYplayed
activitiesr   r    call_activities
   )r   r   Tr#   r$   r   )r%   r&   r   r   c                       e Zd ZdgZy)CallActivity.Meta-created_atNr)   r*   r+   orderingrU   rV   rW   r^   rq   o   	    !?rV   r^   c                     | j                    d| j                  j                          d| j                   d| j                   S )N z at )useractionlowercall
created_atselfs    rW   __str__zCallActivity.__str__r   s:    ))Adkk//12!DII;d4??BSTTrV   N)r)   r*   r+   ACTION_CHOICESr   r=   r   CASCADEr{   r   rx   r5   ry   rO   performed_atrI   duration_playedr^   r   rU   rV   rW   rg   rg   c   s    N
 6TV^^,WD6TV^^J[\DV^DF'6''T2L)f))Qqt[_`O# #UrV   rg   c                   Z   e Zd Z ej                  eej                  d      Z ej                  dddd      Z	 ej                  dddd      Z
 ej                  dd	      Z ej                         Z ej                  d
      Z ej                   dd      Z G d d      Zd Zd Zy)UserMessagereceived_messagesrm   r   Tz<Name of the customer who sent or is related to this message.)r   r   r   	help_text   z<Customer phone number. Store as text to preserve formatting.)r   r   Fr   r'   c                       e Zd ZdgZy)UserMessage.Metarr   Nrs   rU   rV   rW   r^   r      ru   rV   r^   c                     | j                   s5d| _         t        j                         | _        | j	                  ddg       y y NTis_readrT   )update_fieldsr   r   nowrT   saver}   s    rW   mark_as_readzUserMessage.mark_as_read   5    ||DL#<<>DLIIY	$:I; rV   c                 ~    d| j                    d| j                  j                  j                   d| j                   dS )Nz
        Message from z to 
        z 
        | Read: 
)customer_name	recipientprofile	full_namer   r}   s    rW   r   zUserMessage.__str__   sK    (() *					)	)* +  	rV   N)r)   r*   r+   r   r=   r   r   r   r5   r   customer_numbersubjectrC   bodyBooleanFieldr   rO   rT   r^   r   r   rU   rV   rW   r   r   x   s    !!!..(I
 %F$$P	M 'f&&P	O f#T:G6D!f!!%0G"f""D9G# #<rV   r   c                       e Zd ZdZdZy)NotificationType)r   zMissed Call)r   MessageN)r)   r*   r+   MISSED_CALLMESSAGErU   rV   rW   r   r      s    "KGrV   r   c                      e Zd Z ej                  eej                  d      Z ej                  e	j                  d      Z ej                  eej                  dddd      Z ej                  ddd      Z ej"                  dd	      Z ej&                  d
      Z ej*                  dd	      Z ej*                  d      Zd Z G d d      Zd Zy)Notificationnotificationsrm   T)r   db_indexz9Optional reference to the call this notification is about)r   r   r   r    r   r   r   r"   Fr   )auto_now_addc                     | j                   s5d| _         t        j                         | _        | j	                  ddg       y y r   r   r}   s    rW   r   zNotification.mark_as_read   r   rV   c                   f    e Zd Z ej                  ddg       ej                  ddg      gZdgZy)Notification.Metar   r   )fieldsr|   rr   N)r)   r*   r+   r   Indexindexesrt   rU   rV   rW   r^   r      s8    FLLi 89FLLl ;<

 "?rV   r^   c                     t        | j                  j                  d| j                  j                        }d| d| j                   S )Nr   zNotification to z	 | Read: )getattrr   r   usernamer   )r~   names     rW   r   zNotification.__str__   s;    t~~--{DNN<S<ST!$y??rV   N)r)   r*   r+   r   r=   r   r   r   r9   r   r   notification_typer   r>   r{   r5   titlerC   messager   r   rO   rT   r|   r   r^   r   rU   rV   rW   r   r      s    !!!..$I 100 ((
 6//$MD F4dCEfT5G!f!!%0G"f""D9G%%%48J<# #@rV   r   N)	django.dbr   apps.companies.modelsr   apps.core.modelsr   django.utilsr   coresite.mixinr   apps.calls.constantsr   r	   r   rY   rg   r   IntegerChoicesr   Modelr   rU   rV   rW   <module>r      ss     ) ! ! 1 9?:! ?:F!% !,U) U*%( %Tv,, -@6<< -@rV   