Преглед изворни кода

Changed some integers to floats

main
Madiwka пре 1 година
родитељ
комит
9a532739de
12 измењених фајлова са 66 додато и 9 уклоњено
  1. +13
    -0
      app/Dockerfile
  2. +6
    -0
      app/apis/v1/route_user.py
  3. +1
    -0
      app/core/config.py
  4. +2
    -2
      app/db/models/carpart.py
  5. +2
    -2
      app/db/models/fuelingtask.py
  6. +3
    -2
      app/db/models/vehicle.py
  7. +0
    -1
      app/python
  8. +9
    -0
      app/requirements.txt
  9. +1
    -0
      app/schemas/user.py
  10. +1
    -0
      app/start_service.sh
  11. +25
    -0
      docker-compose.yml
  12. +3
    -2
      requirements.txt

+ 13
- 0
app/Dockerfile Прегледај датотеку

@@ -0,0 +1,13 @@
FROM python:3.11-slim

WORKDIR /app
COPY ./requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
ENV PYTHONPATH "${PYTHONPATH}:/app/core:/:/app:/app/app/core:/app/app"
COPY . .



EXPOSE 2764
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "2764"]


+ 6
- 0
app/apis/v1/route_user.py Прегледај датотеку

@@ -4,6 +4,7 @@ from sqlalchemy.orm import Session
from fastapi import Depends
from typing import List, Annotated
from apis.v1.route_auth import get_current_user
from core.config import Settings
from db.models.user import User
from schemas.user import UserCreate, ShowUser, ShowDriver, DriverCreate
from db.session import get_db
@@ -26,6 +27,11 @@ def create_user(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
):
if user.Role not in Settings.ALLOWED_ROLES:
raise HTTPException(
status_code=400,
detail=f"Status {status} is not allowed. Allowed status are {settings.ALLOWED_TASK_STATUS}",
)
if current_user.Role != "Admin":
raise HTTPException(
status_code=403, detail="You are not authorized to perform this action"


+ 1
- 0
app/core/config.py Прегледај датотеку

@@ -11,6 +11,7 @@ class Settings:
SECRET_KEY: str = "tH357aC6oA7ofCaN3yTffYkRh"
ALGORITHM: str = "HS256"
ALLOWED_TASK_STATUS: list = ["Pending", "In Progress", "Completed", "Cancelled"]
ALLOWED_ROLES: list = ["Admin", "Driver", "Maintenance", "Fueling"]


settings = Settings()


+ 2
- 2
app/db/models/carpart.py Прегледај датотеку

@@ -1,4 +1,4 @@
from sqlalchemy import Column, Integer, String, ForeignKey, LargeBinary
from sqlalchemy import Column, Float, Integer, String, ForeignKey, LargeBinary
from sqlalchemy.orm import relationship
from db.base import Base

@@ -12,4 +12,4 @@ class CarPart(Base):
Number = Column(String, nullable=False)
Condition = Column(String, nullable=False)
ImageURL = Column(LargeBinary, nullable=False)
Cost = Column(Integer, nullable=False)
Cost = Column(Float, nullable=False)

+ 2
- 2
app/db/models/fuelingtask.py Прегледај датотеку

@@ -1,4 +1,4 @@
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, LargeBinary
from sqlalchemy import Column, Float, Integer, String, ForeignKey, DateTime, LargeBinary
from sqlalchemy.orm import relationship
from db.base import Base

@@ -11,7 +11,7 @@ class FuelingTask(Base):
Date = Column(DateTime, nullable=False)
Description = Column(String, nullable=True)
Cost = Column(Integer, nullable=False)
FuelRefilled = Column(Integer, nullable=False)
FuelRefilled = Column(Float, nullable=False)
GasStationName = Column(String, nullable=False)
ImageBefore = Column(LargeBinary, nullable=False)
ImageAfter = Column(LargeBinary, nullable=False)


+ 3
- 2
app/db/models/vehicle.py Прегледај датотеку

@@ -1,6 +1,7 @@
# Postgres table model for vehicles
from sqlalchemy import (
Column,
Float,
Integer,
String,
ARRAY,
@@ -16,8 +17,8 @@ class Vehicle(Base):
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)
Fuel = Column(Float, nullable=False)
Mileage = Column(Float, nullable=False)
Status = Column(String, nullable=False)
Capacity = Column(Integer, nullable=False)
DriverHistory = Column(ARRAY(Integer), nullable=True)


+ 0
- 1
app/python Прегледај датотеку

@@ -1 +0,0 @@
/usr/local/bin/python3.10/usr/local/bin/python

+ 9
- 0
app/requirements.txt Прегледај датотеку

@@ -0,0 +1,9 @@
fastapi[all]
pydantic
sqlalchemy
psycopg2-binary
alembic==1.12.0
passlib
python-jose==3.3.0
python-multipart==0.0.6
requests

+ 1
- 0
app/schemas/user.py Прегледај датотеку

@@ -13,6 +13,7 @@ class UserCreate(BaseModel):
GovernmentId: str = Field(...)
Address: str = Field(...)
Email: EmailStr = Field(...)
Role: str = Field(...)


class DriverCreate(UserCreate):


+ 1
- 0
app/start_service.sh Прегледај датотеку

@@ -0,0 +1 @@
uvicorn main:app --host 0.0.0.0 --port 2764

+ 25
- 0
docker-compose.yml Прегледај датотеку

@@ -0,0 +1,25 @@
version: "3.11"

services:
backend:
build: app
ports:
- "8000:2764"
depends_on:
- db


db:
image: "postgres"
restart: always
environment:
POSTGRES_USER: VMSBase
POSTGRES_PASSWORD: VMSBasePass
POSTGRES_DB: VMSData
POSTGRES_PORT: 5432
expose:
- "5432"

networks:
practice:

+ 3
- 2
requirements.txt Прегледај датотеку

@@ -1,8 +1,9 @@
fastapi[all]
pydantic
sqlalchemy
psycopg2
psycopg2-binary
alembic==1.12.0
passlib
python-jose==3.3.0
python-multipart==0.0.6
python-multipart==0.0.6
requests

Loading…
Откажи
Сачувај