
    )i                         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)Company)BotType)Appointment)AppointmentSerializer)AppointmentFilter) AppointmentLimitOffsetPaginationc                   |    e Zd ZdZej
                  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)scheduled_date
created_atr   -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    ||  ==''1D1D1J1J'KTTUfgg,}}++ //$0066 ,  (,-. }}!!## '' ,}}))++,s   3AC -D
DN)__name__
__module____qualname____doc__r
   objectsallr   r   serializer_classr   permission_classesr   pagination_classr   r   r   filter_backendsr   filterset_classsearch_fieldsordering_fieldsorderingr'        r&   r   r      sV    T""&&(H,)*7*L.IO'OYM>O!"H$r7   r   N)rest_frameworkr   rest_framework.permissionsr   rest_framework.filtersr   r   django_filters.rest_frameworkr   apps.companies.modelsr   apps.calls.constantsr	   apps.appointments.modelsr
   apps.appointments.serializersr   apps.appointments.filtersr   apps.appointments.paginationr   ModelViewSetr   r6   r7   r&   <module>rC      s5    # 6 ? = ) ( 0 ? 7 I$ 5 5 $r7   