Compare commits
No commits in common. "beff787801648f986f54633ecc7bc2667b2b39fb" and "f290ea9bd0eb05d38b2c6192b8c1ed54f576fdb6" have entirely different histories.
beff787801
...
f290ea9bd0
@ -12,7 +12,7 @@ router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/events", tags=["events"], response_model=list[events.EventOut])
|
||||
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 = 1, tags: str | None = None, organizers: str | None = None, current_datetime: datetime | None = None, date_event: datetime |None = None, start_date: datetime | None = None, end_date: datetime | None = None):
|
||||
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 = 1, tags: str | None = None, organizers: str | None = None, current_datetime: datetime | None = None, date_event: datetime |None = None):
|
||||
if limit < 1 or skip < 0 or limit < skip:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@ -22,15 +22,9 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
|
||||
listEvents = []
|
||||
event_repository = events.EventRepository(database=database.database)
|
||||
object_search = {}
|
||||
date_selected: bool = False
|
||||
if date_event is not None:
|
||||
start_of_day = datetime.combine(date_event, datetime.min.time()) # 2024-11-23 00:00:00
|
||||
end_of_day = datetime.combine(date_event, datetime.max.time())
|
||||
date_selected = True
|
||||
if start_date is not None and end_date is not None:
|
||||
start_of_day = datetime.combine(start_date, datetime.min.time()) # 2024-11-23 00:00:00
|
||||
end_of_day = datetime.combine(end_date, datetime.max.time())
|
||||
date_selected = True
|
||||
if current_datetime is not None:
|
||||
object_search ={
|
||||
"$or": [{"start_date": {"$gte": current_datetime}}, # Upcoming events
|
||||
@ -43,7 +37,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
|
||||
]}
|
||||
]
|
||||
}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search ={
|
||||
"$and": [{"start_date": {"$gte": start_of_day}},
|
||||
{"start_date": {"$lte": end_of_day}} # Upcoming events
|
||||
@ -66,7 +60,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
|
||||
]
|
||||
}
|
||||
]}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search = { "$and": [ {"status":{"$eq": status}},
|
||||
{"start_date": {"$gte": start_of_day}},
|
||||
{"start_date": {"$lte": end_of_day}}
|
||||
@ -90,7 +84,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
|
||||
}
|
||||
]
|
||||
}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search = {"$and":[{"tags":{"$eq": tags}},
|
||||
{"status":{"$eq":status}},
|
||||
{"start_date": {"$gte": start_of_day}},
|
||||
@ -115,7 +109,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
|
||||
]
|
||||
}
|
||||
]}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search = {"$and":[{"organizers":{"$eq": organizers}},
|
||||
{"status":{"$eq":status}},
|
||||
{"start_date": {"$gte": start_of_day}},
|
||||
@ -140,7 +134,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
|
||||
]
|
||||
}
|
||||
]}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search = {"$and":[{"id":{"$regex": eventid}},
|
||||
{"status":{"$eq":status}},
|
||||
{"start_date": {"$gte": start_of_day}},
|
||||
@ -164,7 +158,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
|
||||
]
|
||||
}
|
||||
]}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search = {"$and":[{"name":{"$regex": name}},
|
||||
{"status":{"$eq":status}},
|
||||
{"start_date": {"$gte": start_of_day}},
|
||||
@ -178,7 +172,7 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
|
||||
|
||||
|
||||
@router.get("/events/search", tags=["events"], response_model=list[events.EventOut])
|
||||
async def search_events(authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin", "User"]))], skip: int = 0, limit: int = 20, item: str | None = None, status: int = 1, min_lat: float | None = None, max_lat: float | None = None, min_lon: float | None = None, max_lon: float | None = None, current_datetime: datetime | None = None, date_event: datetime | None = None, start_date: datetime | None = None, end_date: datetime | None = None):
|
||||
async def search_events(authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin", "User"]))], skip: int = 0, limit: int = 20, item: str | None = None, status: int = 1, min_lat: float | None = None, max_lat: float | None = None, min_lon: float | None = None, max_lon: float | None = None, current_datetime: datetime | None = None, date_event: datetime | None = None):
|
||||
if limit < 1 or skip < 0 or limit < skip:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@ -188,15 +182,9 @@ async def search_events(authorize: Annotated[bool, Depends(permissions_checker.P
|
||||
listEvents = []
|
||||
event_repository = events.EventRepository(database=database.database)
|
||||
object_search = {}
|
||||
date_selected: bool = False
|
||||
if date_event is not None:
|
||||
start_of_day = datetime.combine(date_event, datetime.min.time()) # 2024-11-23 00:00:00
|
||||
end_of_day = datetime.combine(date_event, datetime.max.time())
|
||||
date_selected = True
|
||||
if start_date is not None and end_date is not None:
|
||||
start_of_day = datetime.combine(start_date, datetime.min.time()) # 2024-11-23 00:00:00
|
||||
end_of_day = datetime.combine(dateend_date_event, datetime.max.time())
|
||||
date_selected = True
|
||||
if min_lat is not None and max_lat is not None and min_lon is not None and max_lon is not None:
|
||||
object_search = {
|
||||
"$and": [
|
||||
@ -245,7 +233,7 @@ async def search_events(authorize: Annotated[bool, Depends(permissions_checker.P
|
||||
}
|
||||
]
|
||||
}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search = {
|
||||
"$and": [
|
||||
{"status": {"$eq": status}},
|
||||
@ -303,7 +291,7 @@ async def search_events(authorize: Annotated[bool, Depends(permissions_checker.P
|
||||
}
|
||||
]
|
||||
}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search = {
|
||||
"$and": [
|
||||
{
|
||||
@ -380,7 +368,7 @@ async def search_events(authorize: Annotated[bool, Depends(permissions_checker.P
|
||||
}
|
||||
]
|
||||
}
|
||||
if date_selected is True:
|
||||
if date_event is not None:
|
||||
object_search = {
|
||||
"$and": [
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user