Skip to content

Commit

Permalink
Merge pull request #1 from inteli-city/dev
Browse files Browse the repository at this point in the history
New group RECAPE_SP
  • Loading branch information
GabrielGodoy01 authored Jun 25, 2024
2 parents cf709ae + 409b6d7 commit fcd77f4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
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"

0 comments on commit fcd77f4

Please sign in to comment.