From 9ee7f1cf3aa4d6283b2bd86bfc159a0c4b2b24cd Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 29 Mar 2024 23:25:01 +0100 Subject: [PATCH] add routers ip wip --- app/routers/ipaddress.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/routers/ipaddress.py b/app/routers/ipaddress.py index 74a9969..b4a7c40 100644 --- a/app/routers/ipaddress.py +++ b/app/routers/ipaddress.py @@ -11,7 +11,7 @@ router = APIRouter() @router.get("/ipaddress", tags=["ipaddress"], response_model=list[ipaddress.IpAddressOut]) -async def read_events(authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin", "User"]))], skip: int = 0, limit: int = 20, id_event: str | None = None, name: str | None = None, status: int | None = None): +async def read_events(authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin", "User"]))], skip: int = 0, limit: int = 20, id_ip: str | None = None, ip: str | None = None, status: int | None = None): if limit < 1 or skip < 0 or limit < skip: raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, @@ -23,11 +23,11 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per object_search = {} if status is not None: object_search = {"status":{"$eq": status}} - if id_event is not None: - eventid = ObjectId(id_event) - object_search = {"id": {"$regex": userid}} + if id_ip is not None: + ipid = ObjectId(id_ip) + object_search = {"id": {"$regex": ipid}} if status is not None: - object_search = {"$and":[{"id":{"$regex": eventid}}, {"status":{"$eq":status}}]} + object_search = {"$and":[{"id":{"$regex": ipid}}, {"status":{"$eq":status}}]} if name is not None: object_search = {"name": {"$regex": name}} if status is not None: