Some checks failed
- Add complete hosting module (models, routes, schemas, services, templates, migrations) - Add HostWizard platform to init_production seed (code=hosting, domain=hostwizard.lu) - Fix cms_002 migration down_revision to z_unique_subdomain_domain - Fix prospecting_001 migration to chain after cms_002 (remove branch label) - Add hosting/prospecting version_locations to alembic.ini - Fix admin_services delete endpoint to use proper response model - Add hostwizard.lu to deployment docs (DNS, Caddy, Cloudflare) - Add hosting and prospecting user journey docs to mkdocs nav Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
82 lines
2.3 KiB
Python
82 lines
2.3 KiB
Python
# app/modules/hosting/models/hosted_site.py
|
|
"""
|
|
HostedSite model - links a Store to a Prospect and tracks the POC → live lifecycle.
|
|
|
|
Lifecycle: draft → poc_ready → proposal_sent → accepted → live → suspended | cancelled
|
|
"""
|
|
|
|
import enum
|
|
|
|
from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.core.database import Base
|
|
from models.database.base import TimestampMixin
|
|
|
|
|
|
class HostedSiteStatus(str, enum.Enum):
|
|
DRAFT = "draft"
|
|
POC_READY = "poc_ready"
|
|
PROPOSAL_SENT = "proposal_sent"
|
|
ACCEPTED = "accepted"
|
|
LIVE = "live"
|
|
SUSPENDED = "suspended"
|
|
CANCELLED = "cancelled"
|
|
|
|
|
|
class HostedSite(Base, TimestampMixin):
|
|
"""Represents a hosted website linking a Store to a Prospect."""
|
|
|
|
__tablename__ = "hosted_sites"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
store_id = Column(
|
|
Integer,
|
|
ForeignKey("stores.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
unique=True,
|
|
)
|
|
prospect_id = Column(
|
|
Integer,
|
|
ForeignKey("prospects.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
)
|
|
status = Column(
|
|
Enum(HostedSiteStatus),
|
|
nullable=False,
|
|
default=HostedSiteStatus.DRAFT,
|
|
)
|
|
|
|
# Denormalized for dashboard display
|
|
business_name = Column(String(255), nullable=False)
|
|
contact_name = Column(String(255), nullable=True)
|
|
contact_email = Column(String(255), nullable=True)
|
|
contact_phone = Column(String(50), nullable=True)
|
|
|
|
# Lifecycle timestamps
|
|
proposal_sent_at = Column(DateTime, nullable=True)
|
|
proposal_accepted_at = Column(DateTime, nullable=True)
|
|
went_live_at = Column(DateTime, nullable=True)
|
|
|
|
# Proposal
|
|
proposal_notes = Column(Text, nullable=True)
|
|
|
|
# Denormalized from StoreDomain
|
|
live_domain = Column(String(255), nullable=True, unique=True)
|
|
|
|
# Internal notes
|
|
internal_notes = Column(Text, nullable=True)
|
|
|
|
# Relationships
|
|
store = relationship("Store", backref="hosted_site", uselist=False)
|
|
prospect = relationship("Prospect", backref="hosted_sites")
|
|
client_services = relationship(
|
|
"ClientService",
|
|
back_populates="hosted_site",
|
|
cascade="all, delete-orphan",
|
|
)
|
|
|
|
@property
|
|
def display_name(self) -> str:
|
|
return self.business_name or f"Site #{self.id}"
|