from django.db import models
from django.db.models.deletion import CASCADE
from django.db.models.fields import AutoField, CharField, DateField
from django.contrib.auth.models import AbstractUser

# Create your models here.

class User(models.Model):
    first_name = models.CharField(max_length=255, default="", blank=True, null=True)
    last_name = models.CharField(max_length=255, default="", blank=True, null=True)
    email = models.CharField(max_length=255, blank=True, null=True)
    last_login = models.DateTimeField(blank=True, null=True)
    is_superuser = models.IntegerField(default= 0, blank=False, null=False)
    username = models.CharField(unique=True, max_length=150)
    is_staff = models.IntegerField(default= 0, blank=False, null=False)
    is_active = models.IntegerField(default= 0, blank=False, null=False)
    date_joined = models.DateTimeField(auto_now_add=True)
    user_type_data = ((1, 'Admin'), (2, 'User'), (3, 'Driver'))
    user_type = models.IntegerField(default = 1, choices=user_type_data)
    email = models.CharField(max_length=255, blank=True, null=True)
    name = models.CharField(max_length=255, blank=True, null=True)
    password = models.CharField(max_length=255, blank=True, null=True)
    mobile = models.CharField(max_length=10, blank=True, null = True)
    profile_pic = models.ImageField(upload_to="user_profile", blank=True, null=True)
    fcm_token = models.CharField(null=True, max_length=255)


    class Meta:
        managed = True
        db_table = 'accounts_user'



class DriverPartners(models.Model):
    id : models.AutoField(primary_key=True)
    user = models.ForeignKey(User, default="", null=False, blank=False, on_delete=models.CASCADE, related_name="driver_partner")
    gender_types = ((0, 'Male'),(1, 'Female'))
    gender = models.IntegerField(default=0, choices=gender_types)
    licensce_no = models.CharField(max_length=255, blank=False, null=False)
    date_of_birth = models.CharField(max_length=255, blank=False, null=False)
    experience = models.FloatField(blank=False, null=False)
    location = models.CharField(max_length=255, blank=False, null=False)
    house_number =models.CharField(max_length=255, blank=False, null=False)
    pincode = models.CharField(max_length=255, blank=False, null=False)
    uniform_types = ((0, 'No'), (1, 'Yes'))
    uniform_type = models.IntegerField(default=0, choices=uniform_types)
    station_types = ((0, 'In Station'), (1, 'Out Station'), (2, 'Both'))
    station_type = models.IntegerField(default=0, choices=station_types)
    trip_types = ((0, 'One way'), (1, 'Round'),(2, 'Both'))
    trip_type = models.IntegerField(default=0, choices=trip_types)
    transmission_types = ((0, 'Automatic'), (1, 'Manual'),(2, 'Both'))
    transmission_type = models.IntegerField(default=0, choices=transmission_types)
    created_at = models.DateTimeField(auto_now_add=True)   
    updated_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        managed = True
        db_table = 'driver_partners_driverpartners'


class DriverVehicles(models.Model):
    id : models.AutoField(primary_key=True)
    driver = models.ForeignKey(User, on_delete=models.CASCADE, blank=False, null=False, related_name="driver_vehicles")
    vehicle_model_types = ((0, 'Suv'), (1, 'Sedan'), (2, 'Luxury'),(3, 'Hatchback'))
    vehicle_model = models.IntegerField(default=0, choices=vehicle_model_types)

    class Meta:
        managed = True
        db_table = 'driver_partners_drivervehicles'
