fix: Allow PDF access for users with recommended vehicles
This commit is contained in:
@@ -1836,7 +1836,7 @@ async def get_car_performance_check_pdf(
|
||||
if not performance_check.pdf_path:
|
||||
raise HTTPException(status_code=404, detail="PDF not available for this car")
|
||||
|
||||
# Check access (admin, purchased performance check, or purchased car view)
|
||||
# Check access (admin, purchased performance check, purchased car view, or recommended vehicle)
|
||||
has_access = False
|
||||
if current_user.is_admin:
|
||||
has_access = True
|
||||
@@ -1853,7 +1853,14 @@ async def get_car_performance_check_pdf(
|
||||
CarView.car_id == car_id
|
||||
).first()
|
||||
|
||||
has_access = (existing_perf_view is not None) or (existing_car_view is not None)
|
||||
# Check 3: Car was recommended to user via vehicle request
|
||||
recommended_vehicle = db.query(RequestVehicle).join(VehicleRequest).filter(
|
||||
VehicleRequest.user_id == current_user.id,
|
||||
RequestVehicle.car_id == car_id,
|
||||
RequestVehicle.is_approved == True
|
||||
).first()
|
||||
|
||||
has_access = (existing_perf_view is not None) or (existing_car_view is not None) or (recommended_vehicle is not None)
|
||||
|
||||
if not has_access:
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user