diff --git a/app/core/config.py b/app/core/config.py index 47e4f74..191fb97 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -29,7 +29,8 @@ def createAdminAcc(): LastName="Turgunov", ContactNumber="+77071234567", Role="Admin", - BirthDate="2000-01-01T00:00:00+06:00", + GovernmentId="123456789", + Address="Nazarbayev University", ) if db.query(User).filter(User.Email == user.Email).first(): return False diff --git a/app/db/models/user.py b/app/db/models/user.py index 6f328fc..26f25ec 100644 --- a/app/db/models/user.py +++ b/app/db/models/user.py @@ -1,5 +1,5 @@ # PostgreSQL table model for users -from sqlalchemy import Column, Integer, String, DateTime, ForeignKey +from sqlalchemy import Column, Integer, String, ForeignKey from sqlalchemy.orm import relationship from db.base import Base @@ -9,7 +9,8 @@ class User(Base): Name = Column(String, nullable=False) MiddleName = Column(String, nullable=True) LastName = Column(String, nullable=False) - BirthDate = Column(DateTime, nullable=False) + GovernmentId = Column(String, nullable=False) + Address = Column(String, nullable=False) ContactNumber = Column(String, nullable=False) Email = Column(String, nullable=False) Role = Column(String, nullable=False) diff --git a/app/db/models/vehicle.py b/app/db/models/vehicle.py index 1c3adce..1d6bf86 100644 --- a/app/db/models/vehicle.py +++ b/app/db/models/vehicle.py @@ -14,10 +14,11 @@ class Vehicle(Base): Model = Column(String, nullable=False) Year = Column(Integer, nullable=False) LicensePlate = Column(String, nullable=False) + Type = Column(String, nullable=False) CurrentLocation = Column(ARRAY(String), nullable=True) Fuel = Column(Integer, nullable=False) Mileage = Column(Integer, nullable=False) Status = Column(String, nullable=False) Capacity = Column(Integer, nullable=False) - MaintenanceNotes = Column(ARRAY(String), nullable=True) + DriverHistory = Column(ARRAY(Integer), nullable=True) driver = relationship("User", back_populates="vehicle") diff --git a/app/db/repository/user.py b/app/db/repository/user.py index 6737f48..64b3068 100644 --- a/app/db/repository/user.py +++ b/app/db/repository/user.py @@ -12,7 +12,8 @@ def create_new_user(user: UserCreate, db: Session): Name=user.Name, MiddleName=user.MiddleName, LastName=user.LastName, - BirthDate=user.BirthDate, + GovernmentId=user.GovernmentId, + Address=user.Address, ContactNumber=user.ContactNumber, Role=user.Role, HashedPassword=Hasher.get_password_hash(user.Password), diff --git a/app/db/repository/vehicle.py b/app/db/repository/vehicle.py index 572482f..2498bcf 100644 --- a/app/db/repository/vehicle.py +++ b/app/db/repository/vehicle.py @@ -78,7 +78,8 @@ def replace_vehicle_data(id: int, vehicle: UpdateVehicle, db: Session): vehicle_object.CurrentLocation = vehicle.CurrentLocation vehicle_object.Fuel = vehicle.Fuel vehicle_object.LicensePlate = vehicle.LicensePlate - vehicle_object.MaintenanceNotes = vehicle.MaintenanceNotes + vehicle_object.DriverHistory = vehicle.DriverHistory + vehicle_object.Type = vehicle.Type vehicle_object.Mileage = vehicle.Mileage vehicle_object.Model = vehicle.Model vehicle_object.Status = vehicle.Status diff --git a/app/schemas/user.py b/app/schemas/user.py index 61ff6a5..2410607 100644 --- a/app/schemas/user.py +++ b/app/schemas/user.py @@ -1,6 +1,5 @@ # Purpose: User schema for pydantic (validation, inside-api usage) -from datetime import datetime from pydantic import BaseModel, EmailStr, Field @@ -11,7 +10,8 @@ class UserCreate(BaseModel): MiddleName: str = Field(None) LastName: str = Field(..., min_length=3, max_length=50) ContactNumber: str = Field(..., min_length=12, max_length=12) - BirthDate: datetime = Field(...) + GovernmentId: str = Field(...) + Address: str = Field(...) Email: EmailStr = Field(...) Role: str = Field(..., min_length=3, max_length=50) @@ -22,7 +22,8 @@ class ShowUser(BaseModel): MiddleName: str | None LastName: str ContactNumber: str - BirthDate: datetime + GovernmentId: str + Address: str Email: EmailStr Role: str AssignedVehicle: int | None diff --git a/app/schemas/vehicle.py b/app/schemas/vehicle.py index 7eb2ce7..70ee787 100644 --- a/app/schemas/vehicle.py +++ b/app/schemas/vehicle.py @@ -18,23 +18,15 @@ class OutputVehicle(BaseModel): Mileage: int CurrentLocation: Optional[list[str]] = None Fuel: Optional[int] = 0 - MaintenanceNotes: Optional[list[str]] = None + Type: str + DriverHistory: Optional[list[int]] = None AssignedDriver: Optional[int] = None Capacity: int Status: str -class UpdateVehicle(BaseModel): - Model: str - Year: int - LicensePlate: str - Capacity: int - Mileage: int - Status: str - CurrentLocation: Optional[list[str]] = None - Fuel: Optional[int] = 0 - MaintenanceNotes: Optional[list[str]] = None - AssignedDriver: Optional[int] = None +class UpdateVehicle(OutputVehicle): + pass class VehicleLocation(BaseModel):