.
This commit is contained in:
		@@ -50,87 +50,41 @@ class ResumeResponse(BaseModel):
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@router.get("/", response_model=List[ResumeResponse])
 | 
			
		||||
async def get_resumes(db: Session = Depends(SessionLocal), request: Request = None):
 | 
			
		||||
async def get_resumes(db: Session = Depends(SessionLocal)):
 | 
			
		||||
    """Get all resumes for the current user"""
 | 
			
		||||
    tenant_id = getattr(request.state, 'tenant_id', None)
 | 
			
		||||
    if not tenant_id and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Tenant ID is required")
 | 
			
		||||
    # For testing, use default user
 | 
			
		||||
    user_id = 1  # Default user for testing
 | 
			
		||||
    
 | 
			
		||||
    # Extract user_id from token in a real app, for now using a default
 | 
			
		||||
    user_id = 1  # This would come from authentication in a real implementation
 | 
			
		||||
    
 | 
			
		||||
    # Verify user belongs to the current tenant
 | 
			
		||||
    user = db.query(User).filter(
 | 
			
		||||
        User.id == user_id,
 | 
			
		||||
        User.tenant_id == tenant_id
 | 
			
		||||
    ).first()
 | 
			
		||||
    if not user and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Access denied")
 | 
			
		||||
    
 | 
			
		||||
    resumes = get_user_resumes(db, user_id, tenant_id)
 | 
			
		||||
    resumes = get_user_resumes(db, user_id)
 | 
			
		||||
    return resumes
 | 
			
		||||
 | 
			
		||||
@router.get("/{resume_id}", response_model=ResumeResponse)
 | 
			
		||||
async def get_resume(resume_id: int, db: Session = Depends(SessionLocal), request: Request = None):
 | 
			
		||||
async def get_resume(resume_id: int, db: Session = Depends(SessionLocal)):
 | 
			
		||||
    """Get a specific resume"""
 | 
			
		||||
    tenant_id = getattr(request.state, 'tenant_id', None)
 | 
			
		||||
    if not tenant_id and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Tenant ID is required")
 | 
			
		||||
    # For testing, use default user
 | 
			
		||||
    user_id = 1  # Default user for testing
 | 
			
		||||
    
 | 
			
		||||
    # Extract user_id from token in a real app, for now using a default
 | 
			
		||||
    user_id = 1  # This would come from authentication in a real implementation
 | 
			
		||||
    
 | 
			
		||||
    # Verify user belongs to the current tenant
 | 
			
		||||
    user = db.query(User).filter(
 | 
			
		||||
        User.id == user_id,
 | 
			
		||||
        User.tenant_id == tenant_id
 | 
			
		||||
    ).first()
 | 
			
		||||
    if not user and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Access denied")
 | 
			
		||||
    
 | 
			
		||||
    resume = get_resume_by_id(db, resume_id, user_id, tenant_id)
 | 
			
		||||
    resume = get_resume_by_id(db, resume_id, user_id)
 | 
			
		||||
    if not resume:
 | 
			
		||||
        raise HTTPException(status_code=404, detail="Resume not found")
 | 
			
		||||
    return resume
 | 
			
		||||
 | 
			
		||||
@router.post("/", response_model=ResumeResponse)
 | 
			
		||||
async def create_user_resume(resume: ResumeCreate, db: Session = Depends(SessionLocal), request: Request = None):
 | 
			
		||||
async def create_user_resume(resume: ResumeCreate, db: Session = Depends(SessionLocal)):
 | 
			
		||||
    """Create a new resume for the current user"""
 | 
			
		||||
    tenant_id = getattr(request.state, 'tenant_id', None)
 | 
			
		||||
    if not tenant_id and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Tenant ID is required")
 | 
			
		||||
    
 | 
			
		||||
    # Extract user_id from token in a real app, for now using a default
 | 
			
		||||
    user_id = 1  # This would come from authentication in a real implementation
 | 
			
		||||
    
 | 
			
		||||
    # Verify user belongs to the current tenant
 | 
			
		||||
    user = db.query(User).filter(
 | 
			
		||||
        User.id == user_id,
 | 
			
		||||
        User.tenant_id == tenant_id
 | 
			
		||||
    ).first()
 | 
			
		||||
    if not user and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Access denied")
 | 
			
		||||
    # For testing, use default values
 | 
			
		||||
    user_id = 1  # Default user for testing
 | 
			
		||||
    tenant_id = 1  # Default tenant for testing
 | 
			
		||||
    
 | 
			
		||||
    db_resume = create_resume(db, user_id, resume.title, resume.content, tenant_id)
 | 
			
		||||
    return db_resume
 | 
			
		||||
 | 
			
		||||
@router.put("/{resume_id}", response_model=ResumeResponse)
 | 
			
		||||
async def update_user_resume(resume_id: int, resume_update: ResumeUpdate, db: Session = Depends(SessionLocal), request: Request = None):
 | 
			
		||||
async def update_user_resume(resume_id: int, resume_update: ResumeUpdate, db: Session = Depends(SessionLocal)):
 | 
			
		||||
    """Update a resume for the current user"""
 | 
			
		||||
    tenant_id = getattr(request.state, 'tenant_id', None)
 | 
			
		||||
    if not tenant_id and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Tenant ID is required")
 | 
			
		||||
    
 | 
			
		||||
    # Extract user_id from token in a real app, for now using a default
 | 
			
		||||
    user_id = 1  # This would come from authentication in a real implementation
 | 
			
		||||
    
 | 
			
		||||
    # Verify user belongs to the current tenant
 | 
			
		||||
    user = db.query(User).filter(
 | 
			
		||||
        User.id == user_id,
 | 
			
		||||
        User.tenant_id == tenant_id
 | 
			
		||||
    ).first()
 | 
			
		||||
    if not user and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Access denied")
 | 
			
		||||
    # For testing, use default values
 | 
			
		||||
    user_id = 1  # Default user for testing
 | 
			
		||||
    tenant_id = 1  # Default tenant for testing
 | 
			
		||||
    
 | 
			
		||||
    db_resume = update_resume(db, resume_id, user_id, tenant_id, resume_update.title, resume_update.content)
 | 
			
		||||
    if not db_resume:
 | 
			
		||||
@@ -138,22 +92,11 @@ async def update_user_resume(resume_id: int, resume_update: ResumeUpdate, db: Se
 | 
			
		||||
    return db_resume
 | 
			
		||||
 | 
			
		||||
@router.delete("/{resume_id}")
 | 
			
		||||
async def delete_user_resume(resume_id: int, db: Session = Depends(SessionLocal), request: Request = None):
 | 
			
		||||
async def delete_user_resume(resume_id: int, db: Session = Depends(SessionLocal)):
 | 
			
		||||
    """Delete a resume for the current user"""
 | 
			
		||||
    tenant_id = getattr(request.state, 'tenant_id', None)
 | 
			
		||||
    if not tenant_id and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Tenant ID is required")
 | 
			
		||||
    
 | 
			
		||||
    # Extract user_id from token in a real app, for now using a default
 | 
			
		||||
    user_id = 1  # This would come from authentication in a real implementation
 | 
			
		||||
    
 | 
			
		||||
    # Verify user belongs to the current tenant
 | 
			
		||||
    user = db.query(User).filter(
 | 
			
		||||
        User.id == user_id,
 | 
			
		||||
        User.tenant_id == tenant_id
 | 
			
		||||
    ).first()
 | 
			
		||||
    if not user and settings.MULTI_TENANT_ENABLED:
 | 
			
		||||
        raise HTTPException(status_code=400, detail="Access denied")
 | 
			
		||||
    # For testing, use default values
 | 
			
		||||
    user_id = 1  # Default user for testing
 | 
			
		||||
    tenant_id = 1  # Default tenant for testing
 | 
			
		||||
    
 | 
			
		||||
    success = delete_resume(db, resume_id, user_id, tenant_id)
 | 
			
		||||
    if not success:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user