Sistem web pentru rezervarea de birouri și săli de ședință cu flux de aprobare administrativă. Stack: FastAPI + Vue.js 3 + SQLite + TypeScript Features implementate: - Autentificare JWT + Self-registration cu email verification - CRUD Spații, Utilizatori, Settings (Admin) - Calendar interactiv (FullCalendar) cu drag-and-drop - Creare rezervări cu validare (durată, program, overlap, max/zi) - Rezervări recurente (săptămânal) - Admin: aprobare/respingere/anulare cereri - Admin: creare directă rezervări (bypass approval) - Admin: editare orice rezervare - User: editare/anulare rezervări proprii - Notificări in-app (bell icon + dropdown) - Notificări email (async SMTP cu BackgroundTasks) - Jurnal acțiuni administrative (audit log) - Rapoarte avansate (utilizare, top users, approval rate) - Șabloane rezervări (booking templates) - Atașamente fișiere (upload/download) - Conflict warnings (verificare disponibilitate real-time) - Integrare Google Calendar (OAuth2) - Suport timezone (UTC storage + user preference) - 225+ teste backend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
1.6 KiB
Python
37 lines
1.6 KiB
Python
"""Booking model."""
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class Booking(Base):
|
|
"""Booking model for space reservations."""
|
|
|
|
__tablename__ = "bookings"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
|
space_id = Column(Integer, ForeignKey("spaces.id"), nullable=False, index=True)
|
|
title = Column(String, nullable=False)
|
|
description = Column(String, nullable=True)
|
|
start_datetime = Column(DateTime, nullable=False, index=True)
|
|
end_datetime = Column(DateTime, nullable=False, index=True)
|
|
status = Column(
|
|
String, nullable=False, default="pending", index=True
|
|
) # pending/approved/rejected/canceled
|
|
rejection_reason = Column(String, nullable=True)
|
|
cancellation_reason = Column(String, nullable=True)
|
|
approved_by = Column(Integer, ForeignKey("users.id"), nullable=True)
|
|
google_calendar_event_id = Column(String, nullable=True) # Store Google Calendar event ID
|
|
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
|
|
|
# Relationships
|
|
user = relationship("User", foreign_keys=[user_id], backref="bookings")
|
|
space = relationship("Space", foreign_keys=[space_id], backref="bookings")
|
|
approver = relationship("User", foreign_keys=[approved_by], backref="approved_bookings")
|
|
notifications = relationship("Notification", back_populates="booking")
|
|
attachments = relationship("Attachment", back_populates="booking", cascade="all, delete-orphan")
|