Files
LeDiscord/backend/models/event.py
EvanChal dfeaecce73
Some checks failed
Deploy to Development / build-and-deploy (push) Failing after 20s
fix+feat(everything): lot of things
2026-01-25 22:14:48 +01:00

48 lines
2.0 KiB
Python

from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text, Enum as SQLEnum, Float, Boolean
from sqlalchemy.orm import relationship
from datetime import datetime
import enum
from config.database import Base
class ParticipationStatus(enum.Enum):
PRESENT = "present"
ABSENT = "absent"
MAYBE = "maybe"
PENDING = "pending"
class Event(Base):
__tablename__ = "events"
id = Column(Integer, primary_key=True, index=True)
title = Column(String, nullable=False)
description = Column(Text)
location = Column(String)
latitude = Column(Float, nullable=True) # Coordonnée latitude
longitude = Column(Float, nullable=True) # Coordonnée longitude
date = Column(DateTime, nullable=False)
end_date = Column(DateTime)
creator_id = Column(Integer, ForeignKey("users.id"), nullable=False)
cover_image = Column(String)
is_private = Column(Boolean, default=False) # Événement privé ou public
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
# Relationships
creator = relationship("User", back_populates="created_events")
participations = relationship("EventParticipation", back_populates="event", cascade="all, delete-orphan")
albums = relationship("Album", back_populates="event")
class EventParticipation(Base):
__tablename__ = "event_participations"
id = Column(Integer, primary_key=True, index=True)
event_id = Column(Integer, ForeignKey("events.id"), nullable=False)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
status = Column(SQLEnum(ParticipationStatus), default=ParticipationStatus.PENDING)
response_date = Column(DateTime, default=datetime.utcnow)
created_at = Column(DateTime, default=datetime.utcnow)
# Relationships
event = relationship("Event", back_populates="participations")
user = relationship("User", back_populates="event_participations")