Save test environment changes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from app.db.base import Base
|
||||
from .user import User, UserRole
|
||||
from .identity import User, Person, Wallet, UserRole # ÚJ központ
|
||||
from .company import Company, CompanyMember, VehicleAssignment
|
||||
from .organization import Organization, OrgType
|
||||
from .vehicle import (
|
||||
Vehicle,
|
||||
VehicleOwnership,
|
||||
@@ -13,12 +14,12 @@ from .vehicle import (
|
||||
VehicleVariant
|
||||
)
|
||||
|
||||
# Alias a kompatibilitás kedvéért
|
||||
# Aliasok a kompatibilitás kedvéért
|
||||
UserVehicle = Vehicle
|
||||
|
||||
__all__ = [
|
||||
"Base", "User", "UserRole", "Vehicle", "VehicleOwnership", "VehicleBrand",
|
||||
"EngineSpec", "ServiceProvider", "ServiceRecord", "Company",
|
||||
"Base", "User", "Person", "Wallet", "UserRole", "Vehicle", "VehicleOwnership",
|
||||
"VehicleBrand", "EngineSpec", "ServiceProvider", "ServiceRecord", "Company",
|
||||
"CompanyMember", "VehicleAssignment", "UserVehicle", "VehicleCategory",
|
||||
"VehicleModel", "VehicleVariant"
|
||||
"VehicleModel", "VehicleVariant", "Organization", "OrgType"
|
||||
]
|
||||
BIN
backend/app/models/__pycache__/__init__.cpython-312.pyc
Executable file → Normal file
BIN
backend/app/models/__pycache__/__init__.cpython-312.pyc
Executable file → Normal file
Binary file not shown.
BIN
backend/app/models/__pycache__/identity.cpython-312.pyc
Normal file
BIN
backend/app/models/__pycache__/identity.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/app/models/__pycache__/organization.cpython-312.pyc
Normal file
BIN
backend/app/models/__pycache__/organization.cpython-312.pyc
Normal file
Binary file not shown.
73
backend/app/models/identity.py
Normal file
73
backend/app/models/identity.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# backend/app/models/identity.py
|
||||
import uuid
|
||||
import enum
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, JSON, Numeric, text, Enum
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.base import Base
|
||||
|
||||
class UserRole(str, enum.Enum):
|
||||
ADMIN = "admin"
|
||||
USER = "user"
|
||||
SERVICE = "service"
|
||||
FLEET_MANAGER = "fleet_manager"
|
||||
|
||||
class Person(Base):
|
||||
__tablename__ = "persons"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
id_uuid = Column(UUID(as_uuid=True), default=uuid.uuid4, unique=True, nullable=False)
|
||||
|
||||
last_name = Column(String, nullable=False)
|
||||
first_name = Column(String, nullable=False)
|
||||
mothers_name = Column(String, nullable=True)
|
||||
birth_place = Column(String, nullable=True)
|
||||
birth_date = Column(DateTime, nullable=True)
|
||||
|
||||
identity_docs = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
medical_emergency = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
ice_contact = Column(JSON, server_default=text("'{}'::jsonb"))
|
||||
|
||||
users = relationship("User", back_populates="person")
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
email = Column(String, unique=True, index=True, nullable=False)
|
||||
hashed_password = Column(String, nullable=False)
|
||||
|
||||
# Technikai mezők átmentése a régi user.py-ból
|
||||
role = Column(Enum(UserRole), default=UserRole.USER)
|
||||
is_active = Column(Boolean, default=True)
|
||||
is_superuser = Column(Boolean, default=False)
|
||||
is_company = Column(Boolean, default=False)
|
||||
company_name = Column(String, nullable=True)
|
||||
tax_number = Column(String, nullable=True)
|
||||
region_code = Column(String, default="HU")
|
||||
|
||||
is_deleted = Column(Boolean, default=False)
|
||||
deleted_at = Column(DateTime, nullable=True)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
person_id = Column(Integer, ForeignKey("data.persons.id"), nullable=True)
|
||||
|
||||
person = relationship("Person", back_populates="users")
|
||||
wallet = relationship("Wallet", back_populates="user", uselist=False)
|
||||
# Az Organization kapcsolathoz (ha szükséges az import miatt)
|
||||
owned_organizations = relationship("Organization", backref="owner")
|
||||
|
||||
class Wallet(Base):
|
||||
__tablename__ = "wallets"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
user_id = Column(Integer, ForeignKey("data.users.id"), unique=True)
|
||||
coin_balance = Column(Numeric(18, 2), default=0.00)
|
||||
xp_balance = Column(Integer, default=0)
|
||||
|
||||
user = relationship("User", back_populates="wallet")
|
||||
@@ -1,5 +1,5 @@
|
||||
import enum
|
||||
from sqlalchemy import Column, Integer, String, Boolean, Enum, DateTime
|
||||
from sqlalchemy import Column, Integer, String, Boolean, Enum, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.base import Base
|
||||
@@ -10,11 +10,6 @@ class OrgType(str, enum.Enum):
|
||||
FLEET_OWNER = "fleet_owner"
|
||||
CLUB = "club"
|
||||
|
||||
class UITheme(str, enum.Enum):
|
||||
LIGHT = "light"
|
||||
DARK = "dark"
|
||||
SYSTEM = "system"
|
||||
|
||||
class Organization(Base):
|
||||
__tablename__ = "organizations"
|
||||
__table_args__ = {"schema": "data"}
|
||||
@@ -23,14 +18,11 @@ class Organization(Base):
|
||||
name = Column(String, nullable=False)
|
||||
org_type = Column(Enum(OrgType), default=OrgType.INDIVIDUAL)
|
||||
|
||||
# Új UI beállítások a V2-höz
|
||||
theme = Column(Enum(UITheme), default=UITheme.SYSTEM)
|
||||
logo_url = Column(String, nullable=True)
|
||||
# Spec 2.2: Az owner_id a magánszemély flottájának tulajdonosát jelöli
|
||||
owner_id = Column(Integer, ForeignKey("data.users.id"), nullable=True)
|
||||
|
||||
is_active = Column(Boolean, default=True)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
# Kapcsolatok
|
||||
# members = relationship("OrganizationMember", back_populates="organization")
|
||||
vehicles = relationship("UserVehicle", back_populates="current_org")
|
||||
|
||||
# Kapcsolatok (UserVehicle modell megléte esetén)
|
||||
vehicles = relationship("UserVehicle", back_populates="current_org", cascade="all, delete-orphan")
|
||||
@@ -1,34 +1,6 @@
|
||||
import enum
|
||||
from sqlalchemy import Column, Integer, String, Boolean, Date, DateTime
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.base import Base
|
||||
|
||||
class UserRole(str, enum.Enum):
|
||||
ADMIN = "admin"
|
||||
USER = "user"
|
||||
SERVICE = "service"
|
||||
FLEET_MANAGER = "fleet_manager"
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
__table_args__ = {"schema": "data"}
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
email = Column(String, unique=True, index=True, nullable=False)
|
||||
hashed_password = Column(String, nullable=False)
|
||||
first_name = Column(String)
|
||||
last_name = Column(String)
|
||||
birthday = Column(Date, nullable=True)
|
||||
role = Column(String, default=UserRole.USER)
|
||||
is_active = Column(Boolean, default=True)
|
||||
is_superuser = Column(Boolean, default=False)
|
||||
is_company = Column(Boolean, default=False)
|
||||
company_name = Column(String, nullable=True)
|
||||
tax_number = Column(String, nullable=True)
|
||||
region_code = Column(String, default="HU")
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
# DEPRECATED: Minden funkció átkerült az app.models.identity modulba.
|
||||
# Ez a fájl csak a kompatibilitás miatt maradt meg, de táblát nem definiál.
|
||||
from .identity import User, UserRole
|
||||
|
||||
# Kapcsolatok
|
||||
# memberships = relationship("OrganizationMember", back_populates="user", cascade="all, delete-orphan")
|
||||
|
||||
Reference in New Issue
Block a user