From cd237804149bb098868048ccc001d3a6db986565 Mon Sep 17 00:00:00 2001 From: Parker Date: Sun, 10 Nov 2024 23:11:43 -0600 Subject: [PATCH] Remove extra (old) log routes --- api/routes/links_routes.py | 70 -------------------------------------- 1 file changed, 70 deletions(-) diff --git a/api/routes/links_routes.py b/api/routes/links_routes.py index 5ed565b..97b4599 100644 --- a/api/routes/links_routes.py +++ b/api/routes/links_routes.py @@ -100,73 +100,3 @@ async def delete_link( db.commit() return status.HTTP_204_NO_CONTENT - - -@router.get("/{link}/logs", summary="Get all logs associated with a link") -async def get_link_logs( - link: Annotated[str, Path(title="Link to get logs for")], - current_user: Annotated[User, Depends(get_current_user)], - db=Depends(get_db), -): - """ - Get all of the IP logs associated with a link - """ - link = link.upper() - # Get the link and check the owner - link = db.query(Link).filter(Link.link == link).first() - if not link: - raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, detail="Link not found" - ) - if link.owner != current_user.id: - raise HTTPException( - status_code=status.HTTP_401_UNAUTHORIZED, - detail="Link not associated with your account", - ) - - # Get and return all of the logs - ordered by timestamp - logs = ( - db.query(Log) - .filter(Log.link == link.link) - .order_by(Log.timestamp.desc()) - .all() - ) - return logs - - -@router.delete( - "/{link}/logs/{log_id}", - summary="Delete a specific log associated with a link", -) -async def delete_single_log( - link: Annotated[str, Path(title="Link associated with the log to delete")], - log_id: Annotated[int, Path(title="Log ID to delete")], - current_user: Annotated[User, Depends(get_current_user)], - db=Depends(get_db), -): - """ - Delete the specified log associated with a link - """ - link = link.upper() - # Get the link and check the owner - link = db.query(Link).filter(Link.link == link).first() - if not link: - raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, detail="Link not found" - ) - if link.owner != current_user.id: - raise HTTPException( - status_code=status.HTTP_401_UNAUTHORIZED, - detail="Link not associated with your account", - ) - - # Get the log and delete it - log = db.query(Log).filter(Log.id == log_id).first() - if not log: - raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, detail="Log not found" - ) - db.delete(log) - db.commit() - - return status.HTTP_204_NO_CONTENT