o
    di~F                     @   s  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mZ d d
lmZ d dlmZ G dd deZee
eddd ZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZ G dd  d eZ!G d!d" d"eZ"G d#d$ d$eZ#G d%d& d&eZ$G d'd( d(eZ%G d)d* d*eZ&G d+d, d,eZ'G d-d. d.eZ(d/S )0    )
PointField)	GistIndex)MinValueValidatorMaxValueValidator)models)	post_save)receiver)slugify)station_manager)AssetTypeConstantsStationConstants)DocumentsPath)	BaseModelc                   @   s8  e Zd ZdZejdddZejdddZejdddZej	dddZ
ej	dddZejddddZejdddZejdddZejdddZejddZejddZejdddZejdddZejdddZedddZeje ddZejddZ ejdd	Z!ej"dd
dddZ#e$% Z&G dd dZ'dd Z(d
S )StationMastera  
    This is the StationMaster model.
    It represents system stations.

    Attributes:
        name (str): The name of the station.
        address (str): The address of the station.
        description (str): A description of the station.
        phone_number (str): The phone number of the station.
        email (str): The email address of the station.
        website (str): The website URL of the station.
        is_active (bool): Indicates whether the station is active.
        open_time (TimeField): The opening time of the station (nullable).
        close_time (TimeField): The closing time of the station (nullable).
        is_24_hours_open (bool): Indicates if the station is open 24 hours.
        is_parking_free (bool): Indicates if parking at the station is free.
        coordinates (PointField): The geographic coordinates of the station.
        is_owner_or_user (bool): Indicates if the user is the owner or a regular user of the station.
        scarp_id (BigIntegerField): An identifier for the station.

    Meta:
        db_table (str): The database table name for the StationMaster model.

    Methods:
        __str__(): Returns a string representation of the name.
    Tnullblank   )r   r   
max_length)r   F)choicesr   defaultN   )uniquer   r   r   c                   @   sB   e Zd ZdZejdgdejdgdejdgdedgdgZdS )zStationMaster.MetaZstation_mastername)fieldsis_verifiedis_24_hours_opencoordinatesN)__name__
__module____qualname__db_tabler   Indexr   indexes r%   r%   N/var/www/html/evchargy.com/django-station-ev/station_ev/apps/station/models.pyMetaC   s    
r'   c                 C   s   | j  S )N)r   )selfr%   r%   r&   __str__N   s   zStationMaster.__str__))r   r    r!   __doc__r   	CharFieldr   addressdescription	TextFieldZtitle_descriptionZmeta_descriptionphone_number
EmailFieldemailURLFieldZwebsiteBooleanField	is_active	TimeFieldZ	open_timeZ
close_timer   Zis_parking_freeZparking_cost_descriptionr   r   IntegerFieldr   get_choicesZis_owner_or_userBigIntegerFieldZscarp_idr   	SlugFieldslugr
   ZStationManagerobjectsr'   r)   r%   r%   r%   r&   r      s4    r   )senderc                 K   s2   |rt |j d|j |_|jdgd d S d S )N-r:   )update_fields)r	   r   pkr:   save)r<   instancecreatedkwargsr%   r%   r&   post_save_station_masterR   s   rD   c                   @   sL   e Zd ZdZejdejdddZejeejddZ	e
 ZG dd	 d	Zd
S )StationUseraB  
    This is the StationUser model.
    It represents the association of a user with a station.

    Attributes:
        user (ForeignKey): Relates the user to a station.
        station (ForeignKey): Relates the station to a user.

    Meta:
        db_table (str): The database table name for the StationUser model.
    zaccount.userZuser_stationsT	on_deleterelated_namer   Zstation_usersrG   rH   c                   @      e Zd ZdZdS )zStationUser.MetaZstation_userNr   r    r!   r"   r%   r%   r%   r&   r'   t       r'   N)r   r    r!   r*   r   
ForeignKeyCASCADEuserr   stationr
   ZStationUsersManagerr;   r'   r%   r%   r%   r&   rE   [   s    rE   c                   @   sl   e Zd ZdZejdejdddZejdejdddZejdejd	ddZ	eje
ejd
dZG dd dZdS )StationCountryStateCitya  
    This is the StationCountryStateCity model.
    It represents the association of a station with a country, state, and city.

    Attributes:
        country (ForeignKey): Relates the station to a country.
        state (ForeignKey): Relates the station to a state.
        city (ForeignKey): Relates the station to a city.
        station (ForeignKey): Relates the station to a main station.

    Meta:
        db_table (str): The database table name for the StationCountryStateCity model.
    zmaster.CountryMasterZcountry_stationsTrF   zmaster.StateMasterZstate_stationszmaster.CityMasterZcity_stationsZstation_city_state_countryrI   c                   @   rJ   )zStationCountryStateCity.MetaZstation_country_state_cityNrK   r%   r%   r%   r&   r'      rL   r'   N)r   r    r!   r*   r   rM   rN   countrystateZcityr   rP   r'   r%   r%   r%   r&   rQ   x   s4    rQ   c                   @   st   e Zd ZdZejejdZej	e
 dZejeejddZejdejddZejdd	Ze ZG d
d dZdS )StationMediaa  
    This is the StationMedia model.
    It represents media associated with a station.

    Attributes:
        asset (FileField): The uploaded media file associated with the station.
        asset_type (int): The type of the media (e.g., image, video, audio).
        station (ForeignKey): Relates the media to a station.
        user (ForeignKey): Relates the media to a user who uploaded it.

    Meta:
        db_table (str): The database table name for the StationMedia model.
    	upload_tor   Zstation_mediasrI   account.UserZuser_mediasFr   c                   @   rJ   )zStationMedia.MetaZstation_mediaNrK   r%   r%   r%   r&   r'      rL   r'   N)r   r    r!   r*   r   	FileFieldr   get_station_pathassetr6   r   get_asset_choices
asset_typerM   r   rN   rP   rO   r3   r   r
   ZStationMediaManagerr;   r'   r%   r%   r%   r&   rT      s    rT   c                   @   J   e Zd ZdZejeejddZejdejddZ	e
 ZG dd dZdS )	StationLocationa^  
    This is the StationLocation model.
    It represents the location of a station.

    Attributes:
        station (ForeignKey): Relates the location to a station.
        location (ForeignKey): Relates the location to a specific geographical location.

    Meta:
        db_table (str): The database table name for the StationLocation model.
    station_locationsrI   zmaster.LocationMasterZlocation_stationsc                   @   rJ   )zStationLocation.Metar`   NrK   r%   r%   r%   r&   r'      rL   r'   N)r   r    r!   r*   r   rM   r   rN   rP   locationr
   ZStationLocationsManagerr;   r'   r%   r%   r%   r&   r_          r_   c                   @   s|   e Zd ZdZejeejddZejdejdddZ	ej
dddZejdddZejd	ejd
ddZe ZG dd dZdS )StationConnectorsa  
    This is the StationConnectors model.
    It represents the availability of connectors in a station.

    Attributes:
        station (ForeignKey): Relates the connectors to a station.
        connector (ForeignKey): Relates the connectors to a specific connector type.
        network_operator (ForeignKey): Relates the connectors to a network operator.

    Meta:
        db_table (str): The database table name for the StationConnectors model.
    station_connectorsrI   zmaster.ConnectorMasterZconnector_stationsTrF   r   zmaster.NetworkOperatorMasterZnetwork_operator_stationsc                   @   rJ   )zStationConnectors.Metard   NrK   r%   r%   r%   r&   r'      rL   r'   N)r   r    r!   r*   r   rM   r   rN   rP   	connector
FloatFieldZ	kilowattsr+   Zcost_descriptionnetwork_operatorr
   ZStationConnectorsManagerr;   r'   r%   r%   r%   r&   rc      s*    rc   c                   @   r^   )	StationAmenitiesag  
    This is the StationAmenities model.
    It represents amenities associated with a station.

    Attributes:
        station (ForeignKey): Relates the amenities to a station.
        amenities (ForeignKey): Relates the amenities to a specific type of amenity.

    Meta:
        db_table (str): The database table name for the StationAmenities model.
    station_amenitiesrI   zmaster.AmenitiesMasterZamenities_stationsc                   @   rJ   )zStationAmenities.Metari   NrK   r%   r%   r%   r&   r'     rL   r'   N)r   r    r!   r*   r   rM   r   rN   rP   Z	amenitiesr
   ZStationAmenitiesManagerr;   r'   r%   r%   r%   r&   rh     rb   rh   c                   @   r^   )	BookmarkStationac  
    This is the BookmarkStation model.
    It represents stations that are bookmarked by users.

    Attributes:
        station (ForeignKey): Relates the bookmark to a station.
        user (ForeignKey): Relates the bookmark to a user who added the bookmark.

    Meta:
        db_table (str): The database table name for the BookmarkStation model.
    Zstation_bookmarksrI   rX   Zuser_bookmark_stationsc                   @   rJ   )zBookmarkStation.MetaZbookmark_stationNrK   r%   r%   r%   r&   r'   6  rL   r'   N)r   r    r!   r*   r   rM   r   rN   rP   rO   r
   ZStationBookmarkManagerr;   r'   r%   r%   r%   r&   rj      s    rj   c                   @   sl   e Zd ZdZejeejddZejdejddZ	ej
dddZeje ejdZe ZG d	d
 d
ZdS )SuggestStationa  
    This is the SuggestStation model.
    It represents suggestions of stations sent by end users.

    Attributes:
        station (ForeignKey): Relates the suggestion to a station.
        user (ForeignKey): Relates the suggestion to the user who made the suggestion.
        description (TextField, optional): Additional description for the suggestion.

    Meta:
        db_table (str): The database table name for the SuggestStation model.
    Zstation_suggest_stationsrI   rX   Zuser_suggest_stationsTr   )r   r   c                   @   rJ   )zSuggestStation.Metasuggest_stationNrK   r%   r%   r%   r&   r'   V  rL   r'   N)r   r    r!   r*   r   rM   r   rN   rP   rO   r.   r-   r6   r   Z"get_suggest_station_request_statusPENDINGstatusr
   ZSuggestStationManagerr;   r'   r%   r%   r%   r&   rk   :  s    rk   c                   @   sh   e Zd ZdZejejdZej	e
 dZejeejddZejdejddZe ZG dd	 d	Zd
S )SuggestStationMediaa  
    This is the SuggestStationMedia model.
    It represents media related to suggested stations.

    Attributes:
        asset (FileField): The uploaded media asset.
        asset_type (IntegerField): The type of asset.
        suggest_station (ForeignKey): Relates the media to a suggested station.
        user (ForeignKey): Relates the media to the user who uploaded it.

    Meta:
        db_table (str): The database table name for the SuggestStationMedia model.
    rU   rW   Zsuggest_station_mediasrI   rX   Zuser_suggest_station_mediasc                   @   rJ   )zSuggestStationMedia.MetaZsuggest_station_mediaNrK   r%   r%   r%   r&   r'   v  rL   r'   N)r   r    r!   r*   r   rY   r   get_suggest_station_pathr[   r6   r   r\   r]   rM   rk   rN   rl   rO   r
   ZSuggestStationMediaManagerr;   r'   r%   r%   r%   r&   ro   Z  s    ro   c                   @   s4   e Zd ZdZejdddZe Z	G dd dZ
dS )StationReasonMastera  
    This is the StationReasonMaster model.
    It represents reasons for reporting stations.

    Attributes:
        title (CharField): The title of the reason.

    Meta:
        db_table (str): The database table name for the StationReasonMaster model.
    Fr   r   c                   @   rJ   )zStationReasonMaster.MetaZstation_reason_masterNrK   r%   r%   r%   r&   r'     rL   r'   N)r   r    r!   r*   r   r+   titler
   ZStationReportReasonManagerr;   r'   r%   r%   r%   r&   rq   z  s
    rq   c                   @   sl   e Zd ZdZejeejdddZeje	ejddZ
ejdejddZejddd	Ze ZG d
d dZdS )StationReporta  
    This is the StationReport model.
    It represents reports for stations.

    Attributes:
        reason (ForeignKey): Relates the report to a reason for reporting.
        station (ForeignKey): Relates the report to a station.
        user (ForeignKey): Relates the report to the user who made the report.
        description (TextField, optional): Additional description for the report.

    Meta:
        db_table (str): The database table name for the StationReport model.
    Zreason_station_reportsTrF   Zstation_reportsrI   rX   Zuser_station_reportsrr   c                   @   rJ   )zStationReport.MetaZstation_reportNrK   r%   r%   r%   r&   r'     rL   r'   N)r   r    r!   r*   r   rM   rq   rN   reasonr   rP   rO   r.   r-   r
   ZStationReportManagerr;   r'   r%   r%   r%   r&   rt     s&    rt   c                   @   s`   e Zd ZdZejeejddZejdej	dddZ
ejdej	d	ddZe ZG d
d dZdS )StationCheckInaP  
    This is the StationCheckIn model.
    It represents checkins for stations.

    Attributes:
        station (ForeignKey): Relates the rating to a station.
        user (ForeignKey): Relates the rating to the user who provided the checkIn.
    Meta:
        db_table (str): The database table name for the StationCheckIn model.
    station_checkinrI   rX   Zuser_station_checkinsTrF   zaccount.UserVehicleZuser_vehicles_checkinsc                   @   rJ   )zStationCheckIn.Metarw   NrK   r%   r%   r%   r&   r'     rL   r'   N)r   r    r!   r*   r   rM   r   rN   rP   SET_NULLrO   user_vehicler
   ZStationCheckInManagerr;   r'   r%   r%   r%   r&   rv     s&    rv   c                   @   s   e Zd ZdZejeejddZejdejddZ	ej
dededgd	Zejd
ejdddZejdddZe ZG dd dZdS )StationRatinga   
    This is the StationRating model.
    It represents ratings for stations.

    Attributes:
        station (ForeignKey): Relates the rating to a station.
        user (ForeignKey): Relates the rating to the user who provided the rating.
        rating (FloatField): The numeric rating value.
        label (ForeignKey): Relates the rating to a label for the rating.
        description (TextField, optional): Additional description for the rating.

    Meta:
        db_table (str): The database table name for the StationRating model.
    Zstation_ratingsrI   rX   Zuser_station_ratingsr         )r   
validatorszmaster.RatingLabelMasterZlabel_station_ratingsTrF   rr   c                   @   rJ   )zStationRating.MetaZstation_ratingNrK   r%   r%   r%   r&   r'     rL   r'   N)r   r    r!   r*   r   rM   r   rN   rP   rO   PositiveIntegerFieldr   r   ratingrx   labelr.   r-   r
   ZStationRatingManagerr;   r'   r%   r%   r%   r&   rz     s(    rz   c                   @   sb   e Zd ZdZejeejddZej	e
jdZeje dZejddZe ZG dd	 d	Zd
S )StationRatingMediaa  
    This is the StationRatingMedia model.
    It represents media associated with rating stations.

    Attributes:
        rating_station (ForeignKey): Relates the media to a rating station.
        asset (FileField): The uploaded media asset.
        asset_type (IntegerField): The type of asset.

    Meta:
        db_table (str): The database table name for the StationRatingMedia model.
    Zrating_station_mediasrI   rU   rW   Fr   c                   @   rJ   )zStationRatingMedia.MetaZstation_rating_mediaNrK   r%   r%   r%   r&   r'     rL   r'   N)r   r    r!   r*   r   rM   rz   rN   Zrating_stationrY   r   get_station_rating_pathr[   r6   r   r\   r]   r3   r   r
   ZStationRatingMediaManagerr;   r'   r%   r%   r%   r&   r     s    r   c                   @   sZ   e Zd ZdZejeejddZejdej	dddZ
ejdddZe ZG d	d
 d
ZdS )RejectedStationsz
    Model representing rejected stations.

    This model contains information about stations that have been rejected,
    including the station, the user who rejected it, and the reason for rejection.
    Zstation_rejectedrI   rX   Zuser_station_rejectedTrF   rr   c                   @   rJ   )zRejectedStations.MetaZrejected_stationsNrK   r%   r%   r%   r&   r'   ,  rL   r'   N)r   r    r!   r*   r   rM   r   rN   rP   rx   rO   r.   ru   r
   ZRejectedStationsManagerr;   r'   r%   r%   r%   r&   r     s    r   N))Zdjango.contrib.gis.db.modelsr   Zdjango.contrib.postgres.indexesr   Zdjango.core.validatorsr   r   	django.dbr   Zdjango.db.models.signalsr   django.dispatchr   django.utils.textr	   Zapps.station.managersr
   Zbase.constantsr   r   base.documents_pathr   base.modelsr   r   rD   rE   rQ   rT   r_   rc   rh   rj   rk   ro   rq   rt   rv   rz   r   r   r%   r%   r%   r&   <module>   s:    
C
+&  %"'