1+ import uuid
2+
3+ from sqlalchemy import Column , ForeignKey , DateTime , Enum , Integer , String
4+ from sqlalchemy .dialects .postgresql import UUID
5+ from sqlalchemy .orm import relationship
6+ from datetime import datetime
7+ from sqlalchemy .sql import func
8+
9+ import enum
10+
11+ from .Base import Base
12+
13+ class MatchStatus (enum .Enum ):
14+ PENDING_ADMIN_APPROVAL = "pending_admin_approval"
15+ APPROVED = "approved"
16+ REJECTED = "rejected"
17+
18+ class ScheduleStatus (enum .Enum ):
19+ SCHEDULED = "scheduled"
20+ COMPLETED = "completed"
21+ DECLINED = "declined" # This status is for when a user declines a scheduled match
22+ PENDING_PARTICIPANT_RESPONSE = "pending_participant_response"
23+ PENDING_VOLUNTEER_RESPONSE = "pending_volunteer_response"
24+ CANCELLED = "cancelled" # This status is for when a match is cancelled by an admin
25+
26+ class Matches (Base ):
27+ __tablename__ = "matches"
28+
29+ id = Column (UUID (as_uuid = True ), primary_key = True , default = uuid .uuid4 )
30+
31+ participant_id = Column (UUID (as_uuid = True ), ForeignKey ("users.id" ), nullable = False )
32+ volunteer_id = Column (UUID (as_uuid = True ), ForeignKey ("users.id" ), nullable = False )
33+
34+ match_status = Column (Enum (MatchStatus ), nullable = True , default = MatchStatus .PENDING_ADMIN_APPROVAL )
35+ schedule_status = Column (Enum (ScheduleStatus ), nullable = True )
36+
37+ created_at = Column (DateTime (timezone = True ), server_default = func .now ())
38+ updated_at = Column (DateTime (timezone = True ), server_default = func .now (), onupdate = func .now ())
39+
40+ participant = relationship ("User" , foreign_keys = [participant_id ])
41+ volunteer = relationship ("User" , foreign_keys = [volunteer_id ])
0 commit comments