aggiunti trasferte, export excel, miglioramenti generali
This commit is contained in:
@@ -20,6 +20,8 @@ class PresenceStatus(str, enum.Enum):
|
||||
PRESENT = "present"
|
||||
REMOTE = "remote"
|
||||
ABSENT = "absent"
|
||||
BUSINESS_TRIP = "business_trip"
|
||||
|
||||
|
||||
|
||||
class NotificationType(str, enum.Enum):
|
||||
@@ -67,6 +69,7 @@ class Office(Base):
|
||||
users = relationship("User", back_populates="office")
|
||||
closing_days = relationship("OfficeClosingDay", back_populates="office", cascade="all, delete-orphan")
|
||||
weekly_closing_days = relationship("OfficeWeeklyClosingDay", back_populates="office", cascade="all, delete-orphan")
|
||||
spots = relationship("OfficeSpot", back_populates="office", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class User(Base):
|
||||
@@ -130,7 +133,7 @@ class DailyParkingAssignment(Base):
|
||||
|
||||
id = Column(Text, primary_key=True)
|
||||
date = Column(Date, nullable=False)
|
||||
spot_id = Column(Text, nullable=False) # A1, A2, B1, B2, etc. (prefix from office)
|
||||
spot_id = Column(Text, ForeignKey("office_spots.id", ondelete="CASCADE"), nullable=False)
|
||||
user_id = Column(Text, ForeignKey("users.id", ondelete="SET NULL"))
|
||||
office_id = Column(Text, ForeignKey("offices.id", ondelete="CASCADE"), nullable=False) # Office that owns the spot
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
@@ -138,6 +141,7 @@ class DailyParkingAssignment(Base):
|
||||
# Relationships
|
||||
user = relationship("User", back_populates="assignments", foreign_keys=[user_id])
|
||||
office = relationship("Office")
|
||||
spot = relationship("OfficeSpot", back_populates="assignments")
|
||||
|
||||
__table_args__ = (
|
||||
Index('idx_assignment_office_date', 'office_id', 'date'),
|
||||
@@ -218,7 +222,7 @@ class ParkingExclusion(Base):
|
||||
user = relationship("User", foreign_keys=[user_id])
|
||||
|
||||
__table_args__ = (
|
||||
Index('idx_exclusion_office_user', 'office_id', 'user_id', unique=True),
|
||||
Index('idx_exclusion_office_user', 'office_id', 'user_id'),
|
||||
)
|
||||
|
||||
|
||||
@@ -237,12 +241,6 @@ class NotificationLog(Base):
|
||||
)
|
||||
|
||||
|
||||
class NotificationQueue(Base):
|
||||
"""Queue for pending notifications (for immediate parking change notifications)"""
|
||||
__tablename__ = "notification_queue"
|
||||
|
||||
id = Column(Text, primary_key=True)
|
||||
user_id = Column(Text, ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
||||
notification_type = Column(Enum(NotificationType, values_callable=lambda obj: [e.value for e in obj]), nullable=False) # parking_change
|
||||
subject = Column(Text, nullable=False)
|
||||
body = Column(Text, nullable=False)
|
||||
@@ -252,3 +250,23 @@ class NotificationQueue(Base):
|
||||
__table_args__ = (
|
||||
Index('idx_queue_pending', 'sent_at'),
|
||||
)
|
||||
|
||||
|
||||
class OfficeSpot(Base):
|
||||
"""Specific parking spot definitions (e.g., A1, A2) linked to an office"""
|
||||
__tablename__ = "office_spots"
|
||||
|
||||
id = Column(Text, primary_key=True)
|
||||
office_id = Column(Text, ForeignKey("offices.id", ondelete="CASCADE"), nullable=False)
|
||||
name = Column(Text, nullable=False) # Display name: A1, A2, etc.
|
||||
spot_number = Column(Integer, nullable=False) # Numeric part for sorting/filtering (1, 2, 3...)
|
||||
is_unavailable = Column(Boolean, default=False) # If spot is temporarily out of service
|
||||
|
||||
# Relationships
|
||||
office = relationship("Office", back_populates="spots")
|
||||
assignments = relationship("DailyParkingAssignment", back_populates="spot", cascade="all, delete-orphan")
|
||||
|
||||
__table_args__ = (
|
||||
Index('idx_office_spot_number', 'office_id', 'spot_number', unique=True),
|
||||
Index('idx_office_spot_name', 'office_id', 'name', unique=True),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user