| |
|
|
| import enum |
| from datetime import datetime, timezone |
| from typing import Optional, TYPE_CHECKING |
|
|
| from sqlalchemy import String, DateTime, Text, JSON, Enum as SQLEnum |
| from sqlalchemy.orm import Mapped, mapped_column |
|
|
| from app.models.base import Base |
|
|
| if TYPE_CHECKING: |
| from app.models.user import User |
|
|
|
|
| |
| |
| |
| class ProposalStatus(str, enum.Enum): |
| DRAFT = "DRAFT" |
| SUBMITTED = "SUBMITTED" |
| APPROVED = "APPROVED" |
| REJECTED = "REJECTED" |
|
|
|
|
| |
| |
| |
| class Proposal(Base): |
| __tablename__ = "proposals" |
|
|
| id: Mapped[int] = mapped_column(primary_key=True, index=True) |
|
|
| title: Mapped[str] = mapped_column(String, nullable=False) |
| description: Mapped[Optional[str]] = mapped_column(Text, nullable=True) |
|
|
| status: Mapped[ProposalStatus] = mapped_column( |
| SQLEnum(ProposalStatus), |
| default=ProposalStatus.DRAFT |
| ) |
|
|
| |
| seed_papers_list: Mapped[list] = mapped_column(JSON, default=[]) |
| funder_matches_list: Mapped[list] = mapped_column(JSON, default=[]) |
| gap_analysis: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True) |
|
|
| created_at: Mapped[datetime] = mapped_column( |
| DateTime(timezone=True), |
| default=datetime.now(timezone.utc) |
| ) |
|
|
| updated_at: Mapped[datetime] = mapped_column( |
| DateTime(timezone=True), |
| default=datetime.now(timezone.utc), |
| onupdate=datetime.now(timezone.utc) |
| ) |
|
|
| def __repr__(self) -> str: |
| return f"<Proposal(id={self.id}, title={self.title}, status={self.status})>" |
|
|
|
|
| |
| |
| |
| class FunderCache(Base): |
| __tablename__ = "funder_cache" |
|
|
| id: Mapped[int] = mapped_column(primary_key=True, index=True) |
|
|
| query: Mapped[str] = mapped_column(String, index=True) |
|
|
| results: Mapped[dict] = mapped_column(JSON) |
|
|
| created_at: Mapped[datetime] = mapped_column( |
| DateTime(timezone=True), |
| default=datetime.now(timezone.utc) |
| ) |
|
|
| def __repr__(self): |
| return f"<FunderCache(query={self.query})>" |
|
|
|
|
| |
| |
| |
| class GapCache(Base): |
| __tablename__ = "gap_cache" |
|
|
| id: Mapped[int] = mapped_column(primary_key=True, index=True) |
|
|
| topic: Mapped[str] = mapped_column(String, index=True) |
|
|
| analysis: Mapped[dict] = mapped_column(JSON) |
|
|
| created_at: Mapped[datetime] = mapped_column( |
| DateTime(timezone=True), |
| default=datetime.now(timezone.utc) |
| ) |
|
|
| def __repr__(self): |
| return f"<GapCache(topic={self.topic})>" |
|
|