diff --git a/app/routers/events.py b/app/routers/events.py index 2395b4b..60f5be2 100644 --- a/app/routers/events.py +++ b/app/routers/events.py @@ -73,14 +73,14 @@ async def read_events_count(authorize: Annotated[bool, Depends(permissions_check @router.get("/events/{item_id}", tags=["events"], response_model=events.Event) async def read_events_id(item_id : str, authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))]): - event_repository = event.EventRepository(database=database.database) + event_repository = events.EventRepository(database=database.database) event = event_repository.find_one_by_id(ObjectId(item_id)) return event @router.delete("/events/me/{item_id}", tags=["events"]) async def delete_event_me(item_id: str, current_user: Annotated[users.User, Depends(users_token.get_current_active_user)], authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin", "User"]))], remove: bool = False): - event_repository = event.EventRepository(database=database.database) + event_repository = events.EventRepository(database=database.database) event = event_repository.find_one_by_id(ObjectId(item_id)) if remove is True: event.deleted_at = datetime.today() @@ -120,7 +120,7 @@ async def delete_events_groups(authorize: Annotated[bool, Depends(permissions_ch @router.delete("/events/{item_id}", tags=["events"]) async def delete_events_id(item_id : str, authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))], remove : bool = False): - event_repository = event.EventRepository(database=database.database) + event_repository = events.EventRepository(database=database.database) event = event_repository.find_one_by_id(ObjectId(item_id)) if remove is True: event.status = -1 @@ -130,7 +130,7 @@ async def delete_events_id(item_id : str, authorize: Annotated[bool, Depends(per event.status = 0 event.disabled_at = datetime.today() content = {"message": "events are disabled"} - event.save(user) + event_repository.save(event) response = JSONResponse(content=content) return response @@ -182,7 +182,7 @@ async def update_events_id(item_id: str, authorize: Annotated[bool, Depends(perm status_code=status.HTTP_400_BAD_REQUEST, detail="Body request is empty" ) - event_repository = users.EventRepository(database=database.database) + event_repository = events.EventRepository(database=database.database) event = event_repository.find_one_by({"id": {'$eq': ObjectId(item_id)}}) if event is None: @@ -191,8 +191,8 @@ async def update_events_id(item_id: str, authorize: Annotated[bool, Depends(perm detail="Event not found" ) - event.name = EventSingle.name - event.place = EventSingle.place + event.name = eventSingle.name + event.place = eventSingle.place event.start_date = eventSingle.start_date event.end_date = eventSingle.end_date event.updated_at = datetime.today() @@ -223,7 +223,7 @@ async def patch_events_groups(authorize: Annotated[bool, Depends(permissions_che response = JSONResponse(content=content) return response -@router.patch("/events/{item_id}", tags=["users"]) +@router.patch("/events/{item_id}", tags=["events"]) async def patch_events_id(item_id : str, authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))]): event_repository = events.EventRepository(database=database.database) event = event_repository.find_one_by_id(ObjectId(item_id))