o
    di                     @   s8   d dl mZ d dlmZ d dlmZ G dd deZdS )    )models)StationMasterSerializer)DynamicFieldsModelSerializerc                   @   s2   e Zd ZdZedddZG dd dZdd Zd	S )
StationBookmarkSerializera  
    This is the StationBookmarkSerializer class responsible for serializing and deserializing bookmarked station data.

    It enables users to manage the serialization and deserialization of bookmarked station data,
    allowing for efficient processing of data related to bookmarked stations.

    Meta:
        model (BookmarkStation): The model used for serialization and deserialization.
        fields (tuple): Specifies the fields included in the serialization and deserialization process.
        read_only_fields (tuple): Fields that are marked as read-only.
        extra_kwargs (dict): Additional configurations for specific fields.

    Methods:
        create(validated_data): Creates a new station bookmark and associates it with the requesting user.
    stationT)source	read_onlyc                   @   s&   e Zd ZejZdZdZdddiiZdS )zStationBookmarkSerializer.Meta)idr   userstation_data)r	   r
   r   
write_onlyTN)	__name__
__module____qualname__r   BookmarkStationmodelfieldsread_only_fieldsextra_kwargs r   r   p/var/www/html/evchargy.com/django-station-ev/station_ev/apps/station/serializers/station_bookmark_serializers.pyMeta   s    r   c                 C   s4   | dg }| jd}tjjj||jd\}}|S )a`  
        Create a new station bookmark and associate it with the requesting user.

        Args:
        validated_data (dict): The validated data for creating a new station bookmark.

        Returns:
        BookmarkStation: The created station bookmark.

        This method associates the created station bookmark with the requesting user.
        r   request)r   r
   )popcontextgetr   r   objectsget_or_creater
   )selfvalidated_data
station_idr   r   creater   r   r   r!   !   s   
z StationBookmarkSerializer.createN)r   r   r   __doc__r   r   r   r!   r   r   r   r   r      s
    r   N)apps.stationr   ,apps.station.serializers.station_serializersr   base.serializersr   r   r   r   r   r   <module>   s    