o
    4%i                     @   sD   d dl mZ d dlmZ d dlmZ ddlmZ G dd deZdS )	    )APIView)Responsestatus   )Shopc                   @   s   e Zd ZdZdd ZdS )ShopListViewz4
    View to list all shops with their details.
    c                 C   s   z:t jjdd}g }|D ]"}||j|j|j|j|j|j	|j
|jd|j|j|j|jd qtdd|dtjdW S  tyY } ztdd	t|d
tjdW  Y d }~S d }~ww )NOpenr   )streetcitydistrictstate_or_provincepin_code)uuid	unit_nameunit_locationaddresslatitude	longitude
contact_noemailr   zShops retrieved successfully.)r   messageshopsr   zAn unexpected error occurred.)r   r   	Exception)r   objectsfilterappendr   r   r   r
   r   r   r   r   r   r   r   r   r   r   HTTP_200_OKr   strHTTP_400_BAD_REQUEST)selfrequestr   	shop_listshope r%   5/var/www/html/Testing_prj/Navya-Bakers/shops/views.pyget   sH   
zShopListView.getN)__name__
__module____qualname____doc__r'   r%   r%   r%   r&   r      s    r   N)	rest_framework.viewsr   rest_framework.responser   rest_frameworkr   modelsr   r   r%   r%   r%   r&   <module>   s
    