From 06b50247fda10603d8ac9cdb76ce7cb3d08f3180 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 30 Mar 2024 23:31:31 +0100 Subject: [PATCH] fix events --- app/routers/events.py | 2 +- app/routers/ipaddress.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/routers/events.py b/app/routers/events.py index 68099d5..845f6cc 100644 --- a/app/routers/events.py +++ b/app/routers/events.py @@ -24,7 +24,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per if status is not None: object_search = {"status":{"$eq": status}} if id_event is not None: - eventid = ObjectId(id_event) + eventid = ObjectId(eventid) object_search = {"id": {"$regex": userid}} if status is not None: object_search = {"$and":[{"id":{"$regex": eventid}}, {"status":{"$eq":status}}]} diff --git a/app/routers/ipaddress.py b/app/routers/ipaddress.py index b4a7c40..aa1d338 100644 --- a/app/routers/ipaddress.py +++ b/app/routers/ipaddress.py @@ -2,7 +2,7 @@ from fastapi import APIRouter, Depends, HTTPException, status, Response from fastapi.responses import JSONResponse from datetime import datetime from ..dependencies import users_token, permissions_checker, database -from ..models import events, users +from ..models import ipaddress, users from pydantic import EmailStr from typing import Annotated from bson import ObjectId @@ -19,7 +19,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per ) limit = limit + skip listEvents = [] - event_repository = events.EventRepository(database=database.database) + ip_repository = ipaddress.IpAddressRepository(database=database.database) object_search = {} if status is not None: object_search = {"status":{"$eq": status}} @@ -28,10 +28,10 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per object_search = {"id": {"$regex": ipid}} if status is not None: object_search = {"$and":[{"id":{"$regex": ipid}}, {"status":{"$eq":status}}]} - if name is not None: - object_search = {"name": {"$regex": name}} + if ip is not None: + object_search = {"ip": {"$regex": ip}} if status is not None: - object_search = {"$and":[{"name":{"$regex": name}}, {"status":{"$eq":status}}]} + object_search = {"$and":[{"ip":{"$regex": ip}}, {"status":{"$eq":status}}]} for event_index in event_repository.find_by(object_search, limit=limit, skip=skip):