Implement complete multi-property architecture: - Properties (groups of spaces) with public/private visibility - Property managers (many-to-many) with role-based permissions - Organizations with member management - Anonymous/guest booking support via public API (/api/public/*) - Property-scoped spaces, bookings, and settings - Frontend: property selector, organization management, public booking views - Migration script and updated seed data Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""User model."""
|
|
from sqlalchemy import Boolean, Column, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class User(Base):
|
|
"""User model."""
|
|
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
full_name = Column(String, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
role = Column(String, nullable=False, default="user") # "superadmin"/"manager"/"user"
|
|
organization = Column(String, nullable=True)
|
|
is_active = Column(Boolean, default=True, nullable=False)
|
|
timezone = Column(String(50), default="UTC", nullable=False) # IANA timezone
|
|
|
|
# Relationships
|
|
notifications = relationship("Notification", back_populates="user")
|
|
audit_logs = relationship("AuditLog", back_populates="user")
|
|
booking_templates = relationship("BookingTemplate", back_populates="user")
|
|
google_calendar_token = relationship(
|
|
"GoogleCalendarToken", back_populates="user", uselist=False
|
|
)
|
|
managed_properties = relationship("PropertyManager", backref="user", cascade="all, delete-orphan")
|
|
organization_memberships = relationship("OrganizationMember", backref="user", cascade="all, delete-orphan")
|