Core modules: - Laws: CRUD, search, AI-powered QA - Analysis: legal research and case management - Contracts: lifecycle management with templates - Signatures: electronic signature workflow Infrastructure: - FastAPI + SQLite + async SQLAlchemy - Docker deployment support - 54 unit tests passing Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
"""Case review model."""
|
|
import enum
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import String, Text, DateTime, Enum as SQLEnum, Integer, ForeignKey
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class ReviewStatus(str, enum.Enum):
|
|
"""Review status enumeration."""
|
|
PENDING = "pending"
|
|
APPROVED = "approved"
|
|
REJECTED = "rejected"
|
|
|
|
|
|
class ReviewType(str, enum.Enum):
|
|
"""Review type enumeration."""
|
|
INITIAL = "initial"
|
|
SECONDARY = "secondary"
|
|
FINAL = "final"
|
|
|
|
|
|
class CaseReview(Base):
|
|
"""Case review model."""
|
|
|
|
__tablename__ = "case_reviews"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
case_id: Mapped[int] = mapped_column(Integer, ForeignKey("cases.id"), index=True)
|
|
reviewer_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), index=True)
|
|
review_type: Mapped[ReviewType] = mapped_column(SQLEnum(ReviewType))
|
|
opinion: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
|
score: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
|
|
status: Mapped[ReviewStatus] = mapped_column(
|
|
SQLEnum(ReviewStatus),
|
|
default=ReviewStatus.PENDING
|
|
)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
|
reviewed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
|
|
|
def __init__(
|
|
self,
|
|
case_id: int,
|
|
reviewer_id: int,
|
|
review_type: ReviewType,
|
|
opinion: Optional[str] = None,
|
|
score: Optional[int] = None,
|
|
status: ReviewStatus = ReviewStatus.PENDING,
|
|
**kwargs
|
|
):
|
|
self.case_id = case_id
|
|
self.reviewer_id = reviewer_id
|
|
self.review_type = review_type
|
|
self.opinion = opinion
|
|
self.score = score
|
|
self.status = status
|
|
self.created_at = datetime.utcnow()
|