fix
This commit is contained in:
@@ -84,3 +84,17 @@ async def assign_app_to_user(user_id: int, app_id: int, db: Session = Depends(da
|
||||
db.add(new_assignment)
|
||||
db.commit()
|
||||
return {"message": "Assigned successfully"}
|
||||
|
||||
@router.delete("/{user_id}/assign/{app_id}")
|
||||
async def remove_app_assignment(user_id: int, app_id: int, db: Session = Depends(database.get_db)):
|
||||
assignment = db.query(models.UserApplication).filter(
|
||||
models.UserApplication.user_id == user_id,
|
||||
models.UserApplication.application_id == app_id
|
||||
).first()
|
||||
|
||||
if not assignment:
|
||||
raise HTTPException(status_code=404, detail="Assignment not found")
|
||||
|
||||
db.delete(assignment)
|
||||
db.commit()
|
||||
return {"message": "Assignment removed"}
|
||||
|
||||
Reference in New Issue
Block a user