fix: rename list events
This commit is contained in:
@@ -2,7 +2,7 @@ from api.endpoints.auth import api_router as auth_router
|
||||
from api.endpoints.profile import api_router as profile_router
|
||||
from api.endpoints.account import api_router as account_router
|
||||
from api.endpoints.keyring import api_router as keyring_router
|
||||
from api.endpoints.listevents import api_router as listevents_router
|
||||
from api.endpoints.list_events import api_router as listevents_router
|
||||
from api.endpoints.process_schema import api_router as processschema_router
|
||||
|
||||
list_of_routes = [auth_router, profile_router, account_router, keyring_router, listevents_router, processschema_router]
|
||||
|
@@ -8,12 +8,12 @@ from api.db.connection.session import get_connection_dep
|
||||
|
||||
from api.db.logic.account import get_user_by_login
|
||||
|
||||
from api.db.logic.listevents import (
|
||||
get_listevents_by_name,
|
||||
get_listevents_by_id,
|
||||
create_listevents,
|
||||
update_listevents_by_id,
|
||||
get_listevents_page_DTO,
|
||||
from api.db.logic.list_events import (
|
||||
get_list_events_by_name,
|
||||
get_list_events_by_id,
|
||||
create_list_events,
|
||||
update_list_events_by_id,
|
||||
get_list_events_page_DTO,
|
||||
)
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ from api.schemas.endpoints.list_events import ListEventUpdate, AllListEventRespo
|
||||
from api.services.auth import get_current_user
|
||||
|
||||
from api.services.user_role_validation import (
|
||||
db_user_role_validation_for_listevents_and_processschema_by_listevent_id,
|
||||
db_user_role_validation_for_listevents_and_processschema,
|
||||
db_user_role_validation_for_list_events_and_process_schema_by_list_event_id,
|
||||
db_user_role_validation_for_list_events_and_process_schema,
|
||||
)
|
||||
|
||||
|
||||
api_router = APIRouter(
|
||||
prefix="/listevents",
|
||||
prefix="/list_events",
|
||||
tags=["list events"],
|
||||
)
|
||||
|
||||
@@ -53,8 +53,8 @@ async def get_all_list_events(
|
||||
):
|
||||
filters = {
|
||||
**({"status": status_filter} if status_filter else {}),
|
||||
**({"creator_id": [str(creator_id)]} if creator_id else {}),
|
||||
**({"state": state_filter} if state_filter else {}),
|
||||
**({"creator_id": [str(creator_id)]} if creator_id else {}),
|
||||
}
|
||||
|
||||
filter_dto = ListEventFilterDTO(
|
||||
@@ -64,14 +64,16 @@ async def get_all_list_events(
|
||||
filters=filters if filters else None,
|
||||
)
|
||||
|
||||
authorize_user, page_flag = await db_user_role_validation_for_listevents_and_processschema(connection, current_user)
|
||||
authorize_user, page_flag = await db_user_role_validation_for_list_events_and_process_schema(
|
||||
connection, current_user
|
||||
)
|
||||
|
||||
if not page_flag:
|
||||
if filter_dto.filters is None:
|
||||
filter_dto.filters = {}
|
||||
filter_dto.filters["creator_id"] = [str(authorize_user.id)]
|
||||
|
||||
list_events_page = await get_listevents_page_DTO(connection, filter_dto)
|
||||
list_events_page = await get_list_events_page_DTO(connection, filter_dto)
|
||||
|
||||
if list_events_page is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="List events not found")
|
||||
@@ -79,40 +81,40 @@ async def get_all_list_events(
|
||||
return list_events_page
|
||||
|
||||
|
||||
@api_router.get("/{listevents_id}", dependencies=[Depends(bearer_schema)], response_model=ListEvent)
|
||||
@api_router.get("/{list_events_id}", dependencies=[Depends(bearer_schema)], response_model=ListEvent)
|
||||
async def get_list_events(
|
||||
listevents_id: int,
|
||||
list_events_id: int,
|
||||
connection: AsyncConnection = Depends(get_connection_dep),
|
||||
current_user=Depends(get_current_user),
|
||||
):
|
||||
listevents_validation = await get_listevents_by_id(connection, listevents_id)
|
||||
list_events_validation = await get_list_events_by_id(connection, list_events_id)
|
||||
|
||||
if listevents_validation is None:
|
||||
if list_events_validation is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="List events not found")
|
||||
|
||||
authorize_user = await db_user_role_validation_for_listevents_and_processschema_by_listevent_id(
|
||||
connection, current_user, listevents_validation.creator_id
|
||||
authorize_user = await db_user_role_validation_for_list_events_and_process_schema_by_list_event_id(
|
||||
connection, current_user, list_events_validation.creator_id
|
||||
)
|
||||
|
||||
if listevents_id is None:
|
||||
if list_events_id is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="List events not found")
|
||||
|
||||
return listevents_validation
|
||||
return list_events_validation
|
||||
|
||||
|
||||
@api_router.post("", dependencies=[Depends(bearer_schema)], response_model=ListEvent)
|
||||
async def create_list_events(
|
||||
listevents: ListEventUpdate,
|
||||
list_events: ListEventUpdate,
|
||||
connection: AsyncConnection = Depends(get_connection_dep),
|
||||
current_user=Depends(get_current_user),
|
||||
):
|
||||
user_validation = await get_user_by_login(connection, current_user)
|
||||
listevents_validation = await get_listevents_by_name(connection, listevents.name)
|
||||
list_events_validation = await get_list_events_by_name(connection, list_events.name)
|
||||
|
||||
if listevents_validation is None:
|
||||
await create_listevents(connection, listevents, user_validation.id)
|
||||
listevents_new = await get_listevents_by_name(connection, listevents.name)
|
||||
return listevents_new
|
||||
if list_events_validation is None:
|
||||
await create_list_events(connection, list_events, user_validation.id)
|
||||
list_events_new = await get_list_events_by_name(connection, list_events.name)
|
||||
return list_events_new
|
||||
|
||||
else:
|
||||
raise HTTPException(
|
||||
@@ -120,58 +122,58 @@ async def create_list_events(
|
||||
)
|
||||
|
||||
|
||||
@api_router.put("/{listevents_id}", dependencies=[Depends(bearer_schema)], response_model=ListEvent)
|
||||
@api_router.put("/{list_events_id}", dependencies=[Depends(bearer_schema)], response_model=ListEvent)
|
||||
async def update_list_events(
|
||||
listevents_id: int,
|
||||
listevents_update: ListEventUpdate,
|
||||
list_events_id: int,
|
||||
list_events_update: ListEventUpdate,
|
||||
connection: AsyncConnection = Depends(get_connection_dep),
|
||||
current_user=Depends(get_current_user),
|
||||
):
|
||||
listevents_validation = await get_listevents_by_id(connection, listevents_id)
|
||||
list_events_validation = await get_list_events_by_id(connection, list_events_id)
|
||||
|
||||
if listevents_validation is None:
|
||||
if list_events_validation is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="List events not found")
|
||||
|
||||
authorize_user = await db_user_role_validation_for_listevents_and_processschema_by_listevent_id(
|
||||
connection, current_user, listevents_validation.creator_id
|
||||
authorize_user = await db_user_role_validation_for_list_events_and_process_schema_by_list_event_id(
|
||||
connection, current_user, list_events_validation.creator_id
|
||||
)
|
||||
|
||||
updated_values = listevents_update.model_dump(by_alias=True, exclude_none=True)
|
||||
updated_values = list_events_update.model_dump(by_alias=True, exclude_none=True)
|
||||
|
||||
if not updated_values:
|
||||
return listevents_validation
|
||||
return list_events_validation
|
||||
|
||||
await update_listevents_by_id(connection, updated_values, listevents_validation)
|
||||
await update_list_events_by_id(connection, updated_values, list_events_validation)
|
||||
|
||||
listevents = await get_listevents_by_id(connection, listevents_id)
|
||||
list_events = await get_list_events_by_id(connection, list_events_id)
|
||||
|
||||
return listevents
|
||||
return list_events
|
||||
|
||||
|
||||
@api_router.delete("/{listevents_id}", dependencies=[Depends(bearer_schema)], response_model=ListEvent)
|
||||
@api_router.delete("/{list_events_id}", dependencies=[Depends(bearer_schema)], response_model=ListEvent)
|
||||
async def delete_list_events(
|
||||
listevents_id: int,
|
||||
list_events_id: int,
|
||||
connection: AsyncConnection = Depends(get_connection_dep),
|
||||
current_user=Depends(get_current_user),
|
||||
):
|
||||
listevents_validation = await get_listevents_by_id(connection, listevents_id)
|
||||
list_events_validation = await get_list_events_by_id(connection, list_events_id)
|
||||
|
||||
if listevents_validation is None:
|
||||
if list_events_validation is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="List events not found")
|
||||
|
||||
authorize_user = await db_user_role_validation_for_listevents_and_processschema_by_listevent_id(
|
||||
connection, current_user, listevents_validation.creator_id
|
||||
authorize_user = await db_user_role_validation_for_list_events_and_process_schema_by_list_event_id(
|
||||
connection, current_user, list_events_validation.creator_id
|
||||
)
|
||||
|
||||
listevents_update = ListEventUpdate(status=EventStatus.DELETED.value)
|
||||
list_events_update = ListEventUpdate(status=EventStatus.DELETED.value)
|
||||
|
||||
updated_values = listevents_update.model_dump(by_alias=True, exclude_none=True)
|
||||
updated_values = list_events_update.model_dump(by_alias=True, exclude_none=True)
|
||||
|
||||
if not updated_values:
|
||||
return listevents_validation
|
||||
return list_events_validation
|
||||
|
||||
await update_listevents_by_id(connection, updated_values, listevents_validation)
|
||||
await update_list_events_by_id(connection, updated_values, list_events_validation)
|
||||
|
||||
listevents = await get_listevents_by_id(connection, listevents_id)
|
||||
list_events = await get_list_events_by_id(connection, list_events_id)
|
||||
|
||||
return listevents
|
||||
return list_events
|
@@ -26,8 +26,8 @@ from api.schemas.endpoints.process_schema import ProcessSchemaUpdate, AllProcess
|
||||
from api.services.auth import get_current_user
|
||||
|
||||
from api.services.user_role_validation import (
|
||||
db_user_role_validation_for_listevents_and_processschema_by_listevent_id,
|
||||
db_user_role_validation_for_listevents_and_processschema,
|
||||
db_user_role_validation_for_list_events_and_process_schema_by_list_event_id,
|
||||
db_user_role_validation_for_list_events_and_process_schema,
|
||||
)
|
||||
|
||||
|
||||
@@ -63,7 +63,9 @@ async def get_all_process_schema(
|
||||
filters=filters if filters else None,
|
||||
)
|
||||
|
||||
authorize_user, page_flag = await db_user_role_validation_for_listevents_and_processschema(connection, current_user)
|
||||
authorize_user, page_flag = await db_user_role_validation_for_list_events_and_process_schema(
|
||||
connection, current_user
|
||||
)
|
||||
|
||||
if not page_flag:
|
||||
if filter_dto.filters is None:
|
||||
@@ -89,7 +91,7 @@ async def get_process_schema(
|
||||
if process_schema_validation is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Process schema not found")
|
||||
|
||||
authorize_user = await db_user_role_validation_for_listevents_and_processschema_by_listevent_id(
|
||||
authorize_user = await db_user_role_validation_for_list_events_and_process_schema_by_list_event_id(
|
||||
connection, current_user, process_schema_validation.creator_id
|
||||
)
|
||||
|
||||
@@ -131,7 +133,7 @@ async def update_process_schema(
|
||||
if process_schema_validation is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Process schema not found")
|
||||
|
||||
authorize_user = await db_user_role_validation_for_listevents_and_processschema_by_listevent_id(
|
||||
authorize_user = await db_user_role_validation_for_list_events_and_process_schema_by_list_event_id(
|
||||
connection, current_user, process_schema_validation.creator_id
|
||||
)
|
||||
|
||||
@@ -158,7 +160,7 @@ async def delete_process_schema(
|
||||
if process_schema_validation is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Process schema not found")
|
||||
|
||||
authorize_user = await db_user_role_validation_for_listevents_and_processschema_by_listevent_id(
|
||||
authorize_user = await db_user_role_validation_for_list_events_and_process_schema_by_list_event_id(
|
||||
connection, current_user, process_schema_validation.creator_id
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user