2026.06.05 frontend javítgatás és új belépési logika megvalósítva
This commit is contained in:
@@ -8,6 +8,8 @@ from .identity import (
|
||||
ActiveVoucher,
|
||||
UserTrustProfile,
|
||||
UserRole,
|
||||
Device,
|
||||
UserDeviceLink,
|
||||
)
|
||||
|
||||
from .address import (
|
||||
@@ -38,6 +40,8 @@ __all__ = [
|
||||
"ActiveVoucher",
|
||||
"UserTrustProfile",
|
||||
"UserRole",
|
||||
"Device",
|
||||
"UserDeviceLink",
|
||||
"Address",
|
||||
"GeoPostalCode",
|
||||
"GeoStreet",
|
||||
|
||||
@@ -44,9 +44,9 @@ class Address(Base):
|
||||
id: Mapped[uuid.UUID] = mapped_column(PG_UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
postal_code_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("system.geo_postal_codes.id"))
|
||||
|
||||
street_name: Mapped[str] = mapped_column(String(200), nullable=False)
|
||||
street_type: Mapped[str] = mapped_column(String(50), nullable=False)
|
||||
house_number: Mapped[str] = mapped_column(String(50), nullable=False)
|
||||
street_name: Mapped[Optional[str]] = mapped_column(String(200), nullable=True)
|
||||
street_type: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
|
||||
house_number: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
|
||||
|
||||
stairwell: Mapped[Optional[str]] = mapped_column(String(20))
|
||||
floor: Mapped[Optional[str]] = mapped_column(String(20))
|
||||
@@ -60,6 +60,9 @@ class Address(Base):
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
# Kapcsolat az irányítószám táblához (zip/city lekéréshez)
|
||||
postal_code: Mapped[Optional["GeoPostalCode"]] = relationship("GeoPostalCode", lazy="joined")
|
||||
|
||||
|
||||
|
||||
class Rating(Base):
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
from __future__ import annotations
|
||||
import uuid
|
||||
import enum
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, List, Optional, TYPE_CHECKING
|
||||
from sqlalchemy import String, Boolean, DateTime, ForeignKey, JSON, Numeric, text, Integer, BigInteger, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.dialects.postgresql import UUID as PG_UUID, ENUM as PG_ENUM
|
||||
from sqlalchemy.dialects.postgresql import UUID as PG_UUID, ENUM as PG_ENUM, JSONB
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
# MB 2.0: Központi aszinkron adatbázis motorból húzzuk be a Base-t
|
||||
from app.database import Base
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .address import Address
|
||||
from .organization import Organization, OrganizationMember
|
||||
from .asset import VehicleOwnership
|
||||
from .gamification import UserStats
|
||||
@@ -69,6 +70,14 @@ class Person(Base):
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||
is_ghost: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
||||
|
||||
# Soft KYC: Duplikált személyek összefésülése (merge)
|
||||
merged_into_id: Mapped[Optional[int]] = mapped_column(
|
||||
BigInteger,
|
||||
ForeignKey("identity.persons.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True
|
||||
)
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=func.now(), nullable=False)
|
||||
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
@@ -94,6 +103,13 @@ class Person(Base):
|
||||
nullable=True
|
||||
)
|
||||
|
||||
# Kapcsolat a lakcímhez (system.addresses tábla)
|
||||
address: Mapped[Optional["Address"]] = relationship(
|
||||
"Address",
|
||||
foreign_keys="[Person.address_id]",
|
||||
lazy="joined"
|
||||
)
|
||||
|
||||
memberships: Mapped[List["OrganizationMember"]] = relationship("OrganizationMember", back_populates="person")
|
||||
|
||||
# Kapcsolat a tulajdonolt szervezetekhez (Organization táblában legal_owner_id)
|
||||
@@ -113,7 +129,7 @@ class User(Base):
|
||||
hashed_password: Mapped[Optional[str]] = mapped_column(String)
|
||||
|
||||
role: Mapped[UserRole] = mapped_column(
|
||||
PG_ENUM(UserRole, name="userrole", schema="identity"),
|
||||
PG_ENUM(UserRole, name="userrole", schema="identity"),
|
||||
default=UserRole.user
|
||||
)
|
||||
|
||||
@@ -142,6 +158,10 @@ class User(Base):
|
||||
scope_id: Mapped[Optional[str]] = mapped_column(String(50))
|
||||
custom_permissions: Mapped[Any] = mapped_column(JSON, server_default=text("'{}'::jsonb"))
|
||||
|
||||
# E-mail történetiség és alternatív e-mailek (MB 2.0.1)
|
||||
alternative_emails: Mapped[Any] = mapped_column(JSON, nullable=False, default=list, server_default=text("'[]'::jsonb"))
|
||||
email_history: Mapped[Any] = mapped_column(JSON, nullable=False, default=list, server_default=text("'[]'::jsonb"))
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
# --- KAPCSOLATOK ---
|
||||
@@ -192,7 +212,7 @@ class Wallet(Base):
|
||||
__table_args__ = {"schema": "identity"}
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
||||
user_id: Mapped[int] = mapped_column(Integer, ForeignKey("identity.users.id"), unique=True)
|
||||
user_id: Mapped[int] = mapped_column(Integer, ForeignKey("identity.users.id", ondelete="CASCADE"), unique=True)
|
||||
|
||||
earned_credits: Mapped[float] = mapped_column(Numeric(18, 4), server_default=text("0"))
|
||||
purchased_credits: Mapped[float] = mapped_column(Numeric(18, 4), server_default=text("0"))
|
||||
@@ -263,10 +283,66 @@ class UserTrustProfile(Base):
|
||||
maintenance_score: Mapped[float] = mapped_column(Numeric(5, 2), default=0.0, nullable=False)
|
||||
quality_score: Mapped[float] = mapped_column(Numeric(5, 2), default=0.0, nullable=False)
|
||||
preventive_score: Mapped[float] = mapped_column(Numeric(5, 2), default=0.0, nullable=False)
|
||||
|
||||
# Soft KYC / Identity Trust bővítés
|
||||
identity_score: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
||||
verification_level: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
||||
verified_channels: Mapped[dict] = mapped_column(JSONB, nullable=False, default=dict, server_default=text("'{}'::jsonb"))
|
||||
identity_risk_flag: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
||||
|
||||
last_calculated: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
server_default=func.now(),
|
||||
nullable=False
|
||||
)
|
||||
|
||||
user: Mapped["User"] = relationship("User", back_populates="trust_profile", uselist=False)
|
||||
user: Mapped["User"] = relationship("User", back_populates="trust_profile", uselist=False)
|
||||
|
||||
|
||||
class Device(Base):
|
||||
""" Ismert eszközök (Device Fingerprinting) a Device-Hub architektúrához. """
|
||||
__tablename__ = "devices"
|
||||
__table_args__ = {"schema": "identity"}
|
||||
|
||||
fingerprint_hash: Mapped[str] = mapped_column(String(255), primary_key=True, index=True)
|
||||
risk_score: Mapped[int] = mapped_column(Integer, default=100, nullable=False)
|
||||
is_banned: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
default=lambda: datetime.now(timezone.utc),
|
||||
nullable=False
|
||||
)
|
||||
|
||||
|
||||
class UserDeviceLink(Base):
|
||||
""" Kapcsolótábla a felhasználók és az eszközök között. """
|
||||
__tablename__ = "user_device_links"
|
||||
__table_args__ = {"schema": "identity"}
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(
|
||||
PG_UUID(as_uuid=True),
|
||||
primary_key=True,
|
||||
default=uuid.uuid4
|
||||
)
|
||||
user_id: Mapped[int] = mapped_column(
|
||||
Integer,
|
||||
ForeignKey("identity.users.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True
|
||||
)
|
||||
device_hash: Mapped[str] = mapped_column(
|
||||
String(255),
|
||||
ForeignKey("identity.devices.fingerprint_hash", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True
|
||||
)
|
||||
first_seen_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
default=lambda: datetime.now(timezone.utc),
|
||||
nullable=False
|
||||
)
|
||||
last_seen_at: Mapped[Optional[datetime]] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
nullable=True
|
||||
)
|
||||
login_count: Mapped[int] = mapped_column(Integer, default=1, nullable=False)
|
||||
Reference in New Issue
Block a user