All checks were successful
continuous-integration/drone/push Build is passing
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
import uuid
|
|
|
|
from sqlalchemy import Boolean, Column, Date, Integer, String, Text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from shared.database import BaseModel
|
|
|
|
|
|
class User(BaseModel):
|
|
__tablename__ = "users"
|
|
|
|
uuid = Column(UUID(as_uuid=True), default=uuid.uuid4, unique=True, index=True)
|
|
username = Column(String(50), unique=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
phone = Column(String, unique=True, index=True)
|
|
password_hash = Column(String, nullable=False)
|
|
|
|
# Profile information
|
|
first_name = Column(String(50), nullable=False)
|
|
last_name = Column(String(50), nullable=False)
|
|
date_of_birth = Column(Date)
|
|
avatar_url = Column(String)
|
|
bio = Column(Text)
|
|
|
|
# Отношения (используем lazy import для избежания циклических зависимостей)
|
|
# emergency_contacts = relationship("EmergencyContact", back_populates="user", cascade="all, delete-orphan")
|
|
|
|
# Emergency contacts
|
|
emergency_contact_1_name = Column(String(100))
|
|
emergency_contact_1_phone = Column(String(20))
|
|
emergency_contact_2_name = Column(String(100))
|
|
emergency_contact_2_phone = Column(String(20))
|
|
|
|
# Settings
|
|
location_sharing_enabled = Column(Boolean, default=True)
|
|
emergency_notifications_enabled = Column(Boolean, default=True)
|
|
push_notifications_enabled = Column(Boolean, default=True)
|
|
|
|
# Security
|
|
email_verified = Column(Boolean, default=False)
|
|
phone_verified = Column(Boolean, default=False)
|
|
is_blocked = Column(Boolean, default=False)
|
|
|
|
def __repr__(self):
|
|
return f"<User {self.email}>"
|