feat: Add asesor role with reports-only access - backend v1.0.10, frontend v1.0.16

This commit is contained in:
2025-11-20 16:23:52 -03:00
parent 5d2a96553e
commit 570cdb6739
4 changed files with 30 additions and 22 deletions

View File

@@ -1284,8 +1284,8 @@ def get_dashboard_data(
db: Session = Depends(get_db)
):
"""Obtener datos del dashboard de informes"""
if current_user.role != "admin":
raise HTTPException(status_code=403, detail="Solo administradores pueden acceder a reportes")
if current_user.role not in ["admin", "asesor"]:
raise HTTPException(status_code=403, detail="No tienes permisos para acceder a reportes")
# Construir query base
query = db.query(models.Inspection)
@@ -1531,8 +1531,8 @@ def get_inspections_report(
db: Session = Depends(get_db)
):
"""Obtener lista de inspecciones con filtros"""
if current_user.role != "admin":
raise HTTPException(status_code=403, detail="Solo administradores pueden acceder a reportes")
if current_user.role not in ["admin", "asesor"]:
raise HTTPException(status_code=403, detail="No tienes permisos para acceder a reportes")
# Query base con select_from explícito
query = db.query(

View File

@@ -10,7 +10,7 @@ class User(Base):
username = Column(String(50), unique=True, index=True, nullable=False)
email = Column(String(100), unique=True, index=True)
password_hash = Column(String(255), nullable=False)
role = Column(String(20), nullable=False) # admin, mechanic
role = Column(String(20), nullable=False) # admin, mechanic, asesor
full_name = Column(String(100))
is_active = Column(Boolean, default=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())