fix: rename process schema
This commit is contained in:
@@ -3,7 +3,7 @@ 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.processschema import api_router as processschema_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]
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Query
|
||||
|
||||
from typing import Optional, Dict, Any, List
|
||||
from typing import Optional, List
|
||||
from sqlalchemy.ext.asyncio import AsyncConnection
|
||||
|
||||
from api.db.connection.session import get_connection_dep
|
||||
|
||||
from api.db.logic.account import get_user_by_login
|
||||
|
||||
from api.db.logic.processschema import (
|
||||
from api.db.logic.process_schema import (
|
||||
get_process_schema_by_title,
|
||||
create_process_schema,
|
||||
get_process_schema_by_id,
|
||||
@@ -32,7 +32,7 @@ from api.services.user_role_validation import (
|
||||
|
||||
|
||||
api_router = APIRouter(
|
||||
prefix="/process-schema",
|
||||
prefix="/process_schema",
|
||||
tags=["process schema"],
|
||||
)
|
||||
|
||||
@@ -78,40 +78,40 @@ async def get_all_process_schema(
|
||||
return process_schema_page
|
||||
|
||||
|
||||
@api_router.get("/{processschema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
||||
@api_router.get("/{process_schema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
||||
async def get_process_schema(
|
||||
processschema_id: int,
|
||||
process_schema_id: int,
|
||||
connection: AsyncConnection = Depends(get_connection_dep),
|
||||
current_user=Depends(get_current_user),
|
||||
):
|
||||
processschema_validation = await get_process_schema_by_id(connection, processschema_id)
|
||||
process_schema_validation = await get_process_schema_by_id(connection, process_schema_id)
|
||||
|
||||
if processschema_validation is None:
|
||||
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(
|
||||
connection, current_user, processschema_validation.creator_id
|
||||
connection, current_user, process_schema_validation.creator_id
|
||||
)
|
||||
|
||||
if processschema_id is None:
|
||||
if process_schema_id is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Process schema not found")
|
||||
|
||||
return processschema_validation
|
||||
return process_schema_validation
|
||||
|
||||
|
||||
@api_router.post("", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
||||
async def create_processschema(
|
||||
processschema: ProcessSchemaUpdate,
|
||||
process_schema: ProcessSchemaUpdate,
|
||||
connection: AsyncConnection = Depends(get_connection_dep),
|
||||
current_user=Depends(get_current_user),
|
||||
):
|
||||
user_validation = await get_user_by_login(connection, current_user)
|
||||
processschema_validation = await get_process_schema_by_title(connection, processschema.title)
|
||||
process_schema_validation = await get_process_schema_by_title(connection, process_schema.title)
|
||||
|
||||
if processschema_validation is None:
|
||||
await create_process_schema(connection, processschema, user_validation.id)
|
||||
processschema_new = await get_process_schema_by_title(connection, processschema.title)
|
||||
return processschema_new
|
||||
if process_schema_validation is None:
|
||||
await create_process_schema(connection, process_schema, user_validation.id)
|
||||
process_schema_new = await get_process_schema_by_title(connection, process_schema.title)
|
||||
return process_schema_new
|
||||
|
||||
else:
|
||||
raise HTTPException(
|
||||
@@ -119,58 +119,58 @@ async def create_processschema(
|
||||
)
|
||||
|
||||
|
||||
@api_router.put("/{processschema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
||||
@api_router.put("/{process_schema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
||||
async def update_process_schema(
|
||||
processschema_id: int,
|
||||
processschema_update: ProcessSchemaUpdate,
|
||||
process_schema_id: int,
|
||||
process_schema_update: ProcessSchemaUpdate,
|
||||
connection: AsyncConnection = Depends(get_connection_dep),
|
||||
current_user=Depends(get_current_user),
|
||||
):
|
||||
processschema_validation = await get_process_schema_by_id(connection, processschema_id)
|
||||
process_schema_validation = await get_process_schema_by_id(connection, process_schema_id)
|
||||
|
||||
if processschema_validation is None:
|
||||
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(
|
||||
connection, current_user, processschema_validation.creator_id
|
||||
connection, current_user, process_schema_validation.creator_id
|
||||
)
|
||||
|
||||
updated_values = processschema_update.model_dump(by_alias=True, exclude_none=True)
|
||||
updated_values = process_schema_update.model_dump(by_alias=True, exclude_none=True)
|
||||
|
||||
if not updated_values:
|
||||
return processschema_validation
|
||||
return process_schema_validation
|
||||
|
||||
await update_process_schema_by_id(connection, updated_values, processschema_validation)
|
||||
await update_process_schema_by_id(connection, updated_values, process_schema_validation)
|
||||
|
||||
processschema = await get_process_schema_by_id(connection, processschema_id)
|
||||
process_schema = await get_process_schema_by_id(connection, process_schema_id)
|
||||
|
||||
return processschema
|
||||
return process_schema
|
||||
|
||||
|
||||
@api_router.delete("/{processschema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
||||
@api_router.delete("/{process_schema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
||||
async def delete_process_schema(
|
||||
processschema_id: int,
|
||||
process_schema_id: int,
|
||||
connection: AsyncConnection = Depends(get_connection_dep),
|
||||
current_user=Depends(get_current_user),
|
||||
):
|
||||
processschema_validation = await get_process_schema_by_id(connection, processschema_id)
|
||||
process_schema_validation = await get_process_schema_by_id(connection, process_schema_id)
|
||||
|
||||
if processschema_validation is None:
|
||||
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(
|
||||
connection, current_user, processschema_validation.creator_id
|
||||
connection, current_user, process_schema_validation.creator_id
|
||||
)
|
||||
|
||||
processschema_update = ProcessSchemaUpdate(status=ProcessStatus.DELETED.value)
|
||||
process_schema_update = ProcessSchemaUpdate(status=ProcessStatus.DELETED.value)
|
||||
|
||||
updated_values = processschema_update.model_dump(by_alias=True, exclude_none=True)
|
||||
updated_values = process_schema_update.model_dump(by_alias=True, exclude_none=True)
|
||||
|
||||
if not updated_values:
|
||||
return processschema_validation
|
||||
return process_schema_validation
|
||||
|
||||
await update_process_schema_by_id(connection, updated_values, processschema_validation)
|
||||
await update_process_schema_by_id(connection, updated_values, process_schema_validation)
|
||||
|
||||
processschema = await get_process_schema_by_id(connection, processschema_id)
|
||||
process_schema = await get_process_schema_by_id(connection, process_schema_id)
|
||||
|
||||
return processschema
|
||||
return process_schema
|
Reference in New Issue
Block a user