feat: Space Booking System - MVP complet
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>
This commit is contained in:
41
backend/app/services/audit_service.py
Normal file
41
backend/app/services/audit_service.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Audit service for logging admin actions."""
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.models.audit_log import AuditLog
|
||||
|
||||
|
||||
def log_action(
|
||||
db: Session,
|
||||
action: str,
|
||||
user_id: int,
|
||||
target_type: str,
|
||||
target_id: int,
|
||||
details: Optional[Dict[str, Any]] = None
|
||||
) -> AuditLog:
|
||||
"""
|
||||
Log an admin action to the audit log.
|
||||
|
||||
Args:
|
||||
db: Database session
|
||||
action: Action performed (e.g., 'booking_approved', 'space_created')
|
||||
user_id: ID of the admin user who performed the action
|
||||
target_type: Type of target entity ('booking', 'space', 'user', 'settings')
|
||||
target_id: ID of the target entity
|
||||
details: Optional dictionary with additional information
|
||||
|
||||
Returns:
|
||||
Created AuditLog instance
|
||||
"""
|
||||
audit_log = AuditLog(
|
||||
action=action,
|
||||
user_id=user_id,
|
||||
target_type=target_type,
|
||||
target_id=target_id,
|
||||
details=details or {}
|
||||
)
|
||||
db.add(audit_log)
|
||||
db.commit()
|
||||
db.refresh(audit_log)
|
||||
return audit_log
|
||||
Reference in New Issue
Block a user