o
    di%                     @   s   d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZmZ d dlmZ d dlmZ G dd	 d	eeZG d
d dej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 )    N)AbstractUser)models)timezone)UserManagerUserCodeManagerUserVehicleManagerUserVehicleAssetManagerContactUsManagerContactUsAssetsManagerNewsLetterSubscriberManager)DocumentsPath)	BaseModelc                   @   s   e Zd ZdZejddddZejddddZejdddddZ	ejd	dddZ
ejd
dddZejejddZdZg Ze Zdd ZG dd dZdS )Usera  
    This is the User model.
    It represents registered users in the system.

    Attributes:
        username (str): The username (maximum length 150 characters).
        email (str): The email address (unique, optional).
        mobile_number (str): The mobile number (maximum length 15 characters).
        mobile_country_code (str): The mobile country code (maximum length 5 characters).
        name (str): The user's name (optional, maximum length 30 characters).
        profile_pic (FileField): User's profile picture.

    Authentication:
        - The unique identifier for authentication is the 'mobile_number'.

    Methods:
        __str__(): Returns a string representation of the user.
       F
max_lengthnullblankT)r   r   unique   )r   r   r   r         )r   r   r   	upload_tor   emailc                 C   s   | j  S )N)nameself r   N/var/www/html/evchargy.com/django-station-ev/station_ev/apps/account/models.py__str__6   s   zUser.__str__c                   @      e Zd ZdZdS )z	User.MetausersN__name__
__module____qualname__db_tabler   r   r   r   Meta9       r(   N)r$   r%   r&   __doc__r   	CharFieldusername
EmailFieldr   Zmobile_numberZmobile_country_coder   	FileFieldr   Zget_profile_picture_pathZprofile_picUSERNAME_FIELDREQUIRED_FIELDSr   objectsr    r(   r   r   r   r   r      s    r   c                   @   s`   e Zd ZdZejddZejeej	ddZ
ejejdZe ZG dd dZd	d
 Zdd ZdS )UserCodea  
    This is the UserCode model.

    It manages various types of user codes, such as login codes.

    Attributes:
        code (int): The numeric user code.
        user (ForeignKey): The associated user for whom the code is generated.
        timestamp (DateTimeField): The timestamp when the code was created.

    Meta Options:
        db_table (str): The database table name for this model.

    Methods:
        __str__(): Returns a string representation of the user code.
    T)r   Z
user_codes	on_deleterelated_name)defaultc                   @   r!   )zUserCode.MetaZ	user_codeNr#   r   r   r   r   r(   X   r)   r(   c                 C      d| j  d| j S )z
        Returns a string representation of the user code.

        Returns:
            str: A string with the user's name and the associated code.
        z	Code for  is )usercoder   r   r   r   r    [      zUserCode.__str__c                 C   s   | j t tjdd k S )Nx   )seconds)	timestampr   nowdatetime	timedeltar   r   r   r   
is_expiredd   s   zUserCode.is_expiredN)r$   r%   r&   r*   r   IntegerFieldr:   
ForeignKeyr   CASCADEr9   DateTimeFieldr   r?   r>   r   r1   r(   r    rB   r   r   r   r   r2   =   s    	r2   c                   @   sT   e Zd ZdZejeejddZej	dddZ
ej	dddZG dd dZdd	 Zd
S )UserNotificationa  
    This is the UserNotification model.

    It represents notifications for users.

    Attributes:
        user (ForeignKey): The user to whom the notification is related.
        title (str): The title of the notification (non-null, non-blank).
        description (str): The description of the notification (non-null, non-blank).

    Meta Options:
        db_table (str): The database table name for this model.

    Methods:
        __str__(): Returns a string representation of the user notification.
    Zuser_notificationsr3   Fr   r   c                   @   r!   )zUserNotification.MetaZuser_notificationNr#   r   r   r   r   r(      r)   r(   c                 C   r7   )z
        Returns a string representation of the user notification.

        Returns:
            str: A string with the user's name and the notification title.
        zNotification for r8   )r9   titler   r   r   r   r       r;   zUserNotification.__str__N)r$   r%   r&   r*   r   rD   r   rE   r9   r+   rI   descriptionr(   r    r   r   r   r   rG   h   s    rG   c                   @   s   e Zd ZdZejdejddZejdejddZejdejddZ	eje
ejd	dZejd
d
dZejdd
d
dZe ZG dd dZdd ZdS )UserVehiclea  
    This is the UserVehicle model.

    It represents the vehicles owned by users.

    Attributes:
        vehicle_make (ForeignKey): The make of the vehicle.
        vehicle_model (ForeignKey): The model of the vehicle.
        connector (ForeignKey): The connector type associated with the vehicle.
        user (ForeignKey): The user who owns the vehicle.
        manufacturing_year (DateField): The manufacturing year of the vehicle (non-null, non-blank).
        vehicle_number (str): The vehicle's registration number (maximum length 30 characters, non-null, non-blank).

    Meta Options:
        db_table (str): The database table name for this model.

    Methods:
        __str__(): Returns a string representation of the user's vehicle.
    zvehicle.VehicleMakeMasterZvehicle_make_usersr3   zvehicle.VehicleModelMasterZvehicle_model_userszmaster.ConnectorMasterZconnector_user_vehiclesuser_vehiclesFrH   r   r   c                   @   r!   )zUserVehicle.MetarL   Nr#   r   r   r   r   r(      r)   r(   c                 C   r7   )z
        Returns a string representation of the user's vehicle.

        Returns:
            str: A string with the user's name and the vehicle model.
        zVehicle for r8   )r9   vehicle_modelr   r   r   r   r       r;   zUserVehicle.__str__N)r$   r%   r&   r*   r   rD   rE   Zvehicle_makerM   	connectorr   r9   rC   Zmanufacturing_yearr+   Zvehicle_numberr   r1   r(   r    r   r   r   r   rK      s<    rK   c                   @   sN   e Zd ZdZejeejddZej	e
jddZe ZG dd dZdd	 Zd
S )UserVehicleAssetsag  
    Model class for representing user vehicle assets.

    This model represents assets related to a UserVehicle instance.

    Attributes:
        user_vehicle: ForeignKey to the UserVehicle model, establishing a relationship.
        asset: FileField for storing the asset file.
        objects: Custom manager for querying UserVehicleAsset instances.
    Zuser_vehicle_assetsr3   Tr   c                   @      e Zd ZdZdZdS )zUserVehicleAssets.Meta<
        Meta class to specify database table name.
        Zuser_vehicle_assetNr$   r%   r&   r*   r'   r   r   r   r   r(          r(   c                 C   s   d| j  S )z
        String representation of the UserVehicleAssets instance.

        Returns:
            str: String representation.
        z
Asset for )user_vehicler   r   r   r   r       s   zUserVehicleAssets.__str__N)r$   r%   r&   r*   r   rD   rK   rE   rT   r.   r   Zget_user_vehicleassetr   r1   r(   r    r   r   r   r   rO      s    rO   c                   @   s~   e Zd ZdZejddZejddZejddZ	ejddZ
ejddZejdejddd	d
Ze Ze ZG dd dZdS )	ContactUsa  
    Model class for representing user contact information.

    This model represents user contact information for inquiries.

    Attributes:
        first_name (str): First name of the contact person.
        last_name (str): Last name of the contact person.
        email (str): Email address of the contact person.
        phone_number (str): Phone number of the contact person.
        subject (str): Subject of the contact inquiry.
        contact_request_type (str): Type of the contact request.
        description (str): Description of the contact inquiry.
        objects (UserVehicleAssetManager): Custom manager for querying UserVehicleAsset instances.
    2   )r   d         z!master.ContactUsRequestTypeMasterTZrequest_type_contact_us)r4   r   r   r5   c                   @   rP   )zContactUs.MetarQ   
contact_usNrR   r   r   r   r   r(     rS   r(   N)r$   r%   r&   r*   r   r+   
first_name	last_namer-   r   Zphone_numbersubjectrD   SET_NULLZcontact_request_type	TextFieldrJ   r	   r1   r(   r   r   r   r   rV      s"    rV   c                   @   sD   e Zd ZdZejeejddZej	e
jdZe ZG dd dZdS )ContactUsAssetsa;  
    Model class for representing assets related to contact inquiries.

    This model represents assets related to a ContactUs instance.

    Attributes:
        contact_us (ContactUs): ForeignKey to the ContactUs model, establishing a relationship.
        asset (File): FileField for storing the asset file.
    Zcontact_us_assetsr3   )r   c                   @   rP   )zContactUsAssets.MetarQ   Zassets_contact_usNrR   r   r   r   r   r(   .  rS   r(   N)r$   r%   r&   r*   r   rD   rV   rE   r[   r.   r   Zget_contact_usrU   r
   r1   r(   r   r   r   r   ra     s    
ra   c                   @   s0   e Zd ZdZejddZe ZG dd dZ	dS )NewsLetterSubscriberzz
    Model representing a newsletter subscriber.

    This model stores the email address of a newsletter subscriber.
    T)r   c                   @   rP   )zNewsLetterSubscriber.MetarQ   Znewsletter_subscribersNrR   r   r   r   r   r(   A  rS   r(   N)
r$   r%   r&   r*   r   r-   r   r   r1   r(   r   r   r   r   rb   6  s
    rb   )r@   django.contrib.auth.modelsr   	django.dbr   django.utilsr   Z"apps.account.managers.user_managerr   r   r   r   r	   r
   r   Zbase.documents_pathr   Zbase.modelsr   r   Modelr2   rG   rK   rO   rV   ra   rb   r   r   r   r   <module>   s    $	)+%>&)