ciyidogan commited on
Commit
cc25ecf
·
verified ·
1 Parent(s): aaf2527

Update admin_routes.py

Browse files
Files changed (1) hide show
  1. admin_routes.py +7 -3
admin_routes.py CHANGED
@@ -505,6 +505,7 @@ async def update_version(
505
  project_id: int,
506
  version_id: int,
507
  update: VersionUpdate,
 
508
  username: str = Depends(verify_token)
509
  ):
510
  """Update version"""
@@ -523,9 +524,12 @@ async def update_version(
523
  if version.get("published", False):
524
  raise HTTPException(status_code=400, detail="Cannot update published version")
525
 
526
- # Check race condition
527
- if version.get("last_update_date") != update.last_update_date:
528
- raise HTTPException(status_code=409, detail="Version was modified by another user")
 
 
 
529
 
530
  # Update
531
  version["caption"] = update.caption
 
505
  project_id: int,
506
  version_id: int,
507
  update: VersionUpdate,
508
+ force: bool = False, # Add force parameter
509
  username: str = Depends(verify_token)
510
  ):
511
  """Update version"""
 
524
  if version.get("published", False):
525
  raise HTTPException(status_code=400, detail="Cannot update published version")
526
 
527
+ # Check race condition (skip if force=True)
528
+ if not force and version.get("last_update_date") != update.last_update_date:
529
+ raise HTTPException(
530
+ status_code=409,
531
+ detail="Version was modified by another user. Please reload or force save."
532
+ )
533
 
534
  # Update
535
  version["caption"] = update.caption