Phase 3 completion — Personal Workflow feature set is now complete.
Collections / Watchlists:
- New tables: collections (UUID share_token, slug, public/private) and
collection_bills (unique bill-per-collection constraint)
- Full CRUD API at /api/collections with bill add/remove endpoints
- Public share endpoint /api/collections/share/{token} (no auth)
- /collections list page with inline create form and delete
- /collections/[id] detail page: inline rename, public toggle,
copy-share-link, bill search/add/remove
- CollectionPicker bookmark-icon popover on bill detail pages
- Collections nav link in sidebar (auth-required)
Shareable Brief Links:
- share_token UUID column on bill_briefs (backfilled on migration)
- Unified public share router at /api/share (brief + collection)
- /share/brief/[token] — minimal layout, full AIBriefCard, CTAs
- /share/collection/[token] — minimal layout, bill list, CTA
- Share2 button in BriefPanel header row, "Link copied!" flash
AuthGuard: /collections → AUTH_REQUIRED; /share prefix → NO_SHELL_PATHS
Authored-By: Jack Levy
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
2.2 KiB
Python
52 lines
2.2 KiB
Python
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Index, Integer, String, UniqueConstraint
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class Collection(Base):
|
|
__tablename__ = "collections"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
|
name = Column(String(100), nullable=False)
|
|
slug = Column(String(120), nullable=False)
|
|
is_public = Column(Boolean, nullable=False, default=False, server_default="false")
|
|
share_token = Column(UUID(as_uuid=False), nullable=False, server_default=func.gen_random_uuid())
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
|
|
|
user = relationship("User", back_populates="collections")
|
|
collection_bills = relationship(
|
|
"CollectionBill",
|
|
cascade="all, delete-orphan",
|
|
order_by="CollectionBill.added_at.desc()",
|
|
)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint("user_id", "slug", name="uq_collections_user_slug"),
|
|
UniqueConstraint("share_token", name="uq_collections_share_token"),
|
|
Index("ix_collections_user_id", "user_id"),
|
|
Index("ix_collections_share_token", "share_token"),
|
|
)
|
|
|
|
|
|
class CollectionBill(Base):
|
|
__tablename__ = "collection_bills"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
collection_id = Column(Integer, ForeignKey("collections.id", ondelete="CASCADE"), nullable=False)
|
|
bill_id = Column(String, ForeignKey("bills.bill_id", ondelete="CASCADE"), nullable=False)
|
|
added_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
collection = relationship("Collection", back_populates="collection_bills")
|
|
bill = relationship("Bill")
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint("collection_id", "bill_id", name="uq_collection_bills_collection_bill"),
|
|
Index("ix_collection_bills_collection_id", "collection_id"),
|
|
Index("ix_collection_bills_bill_id", "bill_id"),
|
|
)
|