Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New group RECAPE_SP #1

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/modules/create_user/app/create_user_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .create_user_usecase import CreateUserUsecase
from src.shared.helpers.errors.controller_errors import MissingParameters
from src.shared.helpers.errors.domain_errors import EntityError
from src.shared.helpers.errors.usecase_errors import DuplicatedItem, InvalidCredentials
from src.shared.helpers.errors.usecase_errors import DuplicatedItem, ForbiddenAction, InvalidCredentials
from src.shared.helpers.external_interfaces.external_interface import IRequest, IResponse
from src.shared.helpers.external_interfaces.http_codes import BadRequest, InternalServerError, Conflict, \
Created, Forbidden, Unauthorized
Expand Down Expand Up @@ -69,5 +69,8 @@ def __call__(self, request: IRequest) -> IResponse:
except EntityError as err:
return BadRequest(body=f"Parâmetro inválido: {err.message}")

except ForbiddenAction as err:
return Forbidden(body=err.args[0])

except Exception as err:
return InternalServerError(body=err.args[0])
7 changes: 5 additions & 2 deletions src/modules/get_all_users/app/get_all_users_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from .get_all_users_viewmodel import GetAllUsersViewmodel
from src.shared.helpers.errors.controller_errors import MissingParameters
from src.shared.helpers.errors.domain_errors import EntityError
from src.shared.helpers.errors.usecase_errors import InvalidCredentials, InvalidTokenError, NoItemsFound
from src.shared.helpers.errors.usecase_errors import ForbiddenAction, InvalidCredentials, InvalidTokenError, NoItemsFound
from src.shared.helpers.external_interfaces.external_interface import IRequest, IResponse
from src.shared.helpers.external_interfaces.http_codes import OK, BadRequest, InternalServerError, Unauthorized
from src.shared.helpers.external_interfaces.http_codes import OK, BadRequest, Forbidden, InternalServerError, Unauthorized


class GetAllUsersController:
Expand All @@ -27,6 +27,9 @@ def __call__(self, request: IRequest) -> IResponse:

except MissingParameters as err:
return BadRequest(body=f"Parâmetro ausente: {err.message}")

except ForbiddenAction as err:
return Forbidden(body=err.args[0])

except Exception as err:
return InternalServerError(body=err.args[0])
2 changes: 1 addition & 1 deletion src/modules/get_all_users/app/get_all_users_usecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, repo: IUserRepository):
def __call__(self, requester_role: ROLE) -> List[User]:

if requester_role != ROLE.ADMIN_COLLABORATOR:
raise ForbiddenAction("Usuário não tem permissão para criar usuários")
raise ForbiddenAction("Usuário não tem permissão para listar usuários")

users_response = self.repo.get_all_users()

Expand Down
7 changes: 5 additions & 2 deletions src/modules/update_user/app/update_user_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from src.shared.domain.enums.groups_enum import GROUPS
from src.shared.helpers.errors.controller_errors import MissingParameters
from src.shared.helpers.errors.domain_errors import EntityError
from src.shared.helpers.errors.usecase_errors import InvalidCredentials, InvalidTokenError, NoItemsFound
from src.shared.helpers.errors.usecase_errors import ForbiddenAction, InvalidCredentials, InvalidTokenError, NoItemsFound
from src.shared.helpers.external_interfaces.external_interface import IRequest, IResponse
from src.shared.helpers.external_interfaces.http_codes import OK, BadRequest, InternalServerError, Unauthorized
from src.shared.helpers.external_interfaces.http_codes import OK, BadRequest, Forbidden, InternalServerError, Unauthorized


class UpdateUserController:
Expand Down Expand Up @@ -70,5 +70,8 @@ def __call__(self, request: IRequest) -> IResponse:
except InvalidTokenError as err:
return Unauthorized(body="Token inválido ou expirado")

except ForbiddenAction as err:
return Forbidden(body=err.args[0])

except Exception as err:
return InternalServerError(body=err.args[0])
1 change: 1 addition & 0 deletions src/shared/domain/enums/groups_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ class GROUPS(Enum):
GAIA = "GAIA"
JUNDIAI = "JUNDIAI"
FORMULARIOS = "FORMULARIOS"
RECAPE_SP = "RECAPE_SP"
Loading