
    Ti@                         d dl mZ d dlmZ d dlmZ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 d d	lmZ d d
lmZ  G d dej*                        Zy)    )viewsets)IsAuthenticated)SearchFilterOrderingFilter)DjangoFilterBackend)AppointmentRepository)Company)BotType)AppointmentSerializer)AppointmentFilter) AppointmentLimitOffsetPaginationc                   j    e Zd ZdZ ej
                         ZeZe	gZ
eZeeegZeZg dZg dZdgZd Zy)ServiceAppointmentViewSetzJViewSet for managing Service appointments only (SERVICE_BOT appointments).)nametwilio_call_sidcall__from_numberappointment_phone)
created_atr   r   scheduled_date-scheduled_datec                    | j                   j                  }|j                  rC| j                  j	                  t
        j                  j                        j                  d      S |j                  rO	 | j                  j	                  |j                  t
        j                  j                        j                  d      S | j                  j                         S # t        j                  $ r | j                  j                         cY S w xY w)N)bot_typer   )companyr   )requestuseris_superuserquerysetfilterr
   SERVICE_BOTvalueorder_byactive_companyr	   DoesNotExistnone)selfr   s     U/var/www/html/dp2/backend_v2.1/server/apps/appointments/views/service_appointments.pyget_querysetz&ServiceAppointmentViewSet.get_queryset   s    ||  =='' ,,22 ( h()* ,}}++ //$0066 ,  (,-. }}!!## '' ,}}))++,s   3AC -D
DN)__name__
__module____qualname____doc__r   r'   r   r   serializer_classr   permission_classesr   pagination_classr   r   r   filter_backendsr   filterset_classsearch_fieldsordering_fieldsordering     r&   r   r      sW    T1$113H,)*7*L.IO'OYMO ""H$r5   r   N)rest_frameworkr   rest_framework.permissionsr   rest_framework.filtersr   r   django_filters.rest_frameworkr   apps.appointments.repositoriesr   apps.companies.modelsr	   apps.calls.constantsr
   apps.appointments.serializersr   apps.appointments.filtersr   apps.appointments.paginationr   ModelViewSetr   r4   r5   r&   <module>rA      s5    # 6 ? = @ ) ( ? 7 I"$ 5 5 "$r5   