-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from rodrigmars/main
Ajustes de layout editar transporte
- Loading branch information
Showing
8 changed files
with
204 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from . import errors | ||
from datetime import datetime, time | ||
|
||
|
||
class TransporteCore: | ||
|
||
def __init__(self) -> None: | ||
pass | ||
|
||
def validar_cancelamento(self, data_agendada: datetime) -> None: | ||
|
||
print(">>>>> data_agendada:", data_agendada) | ||
|
||
data_atual = datetime.now() | ||
|
||
# data_atual = datetime(2024, 5, 25, 15, 30) | ||
|
||
duration = data_atual - data_agendada | ||
|
||
hora = data_atual.time().hour | ||
|
||
if duration.days < 1: | ||
|
||
raise errors.CancelarTransporteError( | ||
"Ação não permitida, período limite excedito para o cancelamento", | ||
"O LIMITE PARA CANCELAMENTO É PERMITIDO ATÉ COM 1 DIA DE ANTECEDÊNCIA", | ||
) | ||
|
||
elif duration.days == 1 and hora >= 18: | ||
|
||
raise errors.CancelarTransporteError( | ||
"Ação não permitida, limite de horário excedido", | ||
"O CANCELAMENTO PARA ATÉ 1 DIA DE ANTECENDÊNCIA É PERMITIDO ATÉ ÀS 18HRS", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class TransporteError(Exception): | ||
|
||
def __init__(self, mensagem: str): | ||
self.message = mensagem | ||
|
||
|
||
class CancelarTransporteError(Exception): | ||
|
||
def __init__(self, mensagem: str, descritiva: str): | ||
self.message = mensagem | ||
self.description = descritiva |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,101 @@ | ||
from datetime import datetime, time | ||
# from datetime import datetime, time | ||
|
||
# start_time = time(8, 0, 0) | ||
# end_time = time(17, 0, 0) | ||
# # 1 validação | ||
# # start_time = time(8, 0, 0) | ||
# # end_time = time(17, 0, 0) | ||
|
||
# hora_consulta = time(17, 1, 0) | ||
# # hora_consulta = time(17, 1, 0) | ||
|
||
# if hora_consulta < start_time or hora_consulta > end_time: | ||
# # if hora_consulta < start_time or hora_consulta > end_time: | ||
|
||
# print( | ||
# "Erro: Hora informada deve respeitar janela de atendimento, das 08hrs às 17hrs" | ||
# ) | ||
# # print( | ||
# # "Erro: Hora informada deve respeitar janela de atendimento, das 08hrs às 17hrs" | ||
# # ) | ||
|
||
|
||
STATUS_CHOICES = ((1, "Agendado"), (2, "Cancelado"), (3, "Realizado")) | ||
# # 2 validação | ||
# # STATUS_CHOICES = ((1, "Agendado"), (2, "Cancelado"), (3, "Realizado")) | ||
|
||
users = [("user-kb001", 2), ("user-kb045", 1), ("user-kb025", 3)] | ||
# # users = [("user-kb001", 2), ("user-kb045", 1), ("user-kb025", 3)] | ||
|
||
|
||
def filter_status(data, status_choice): | ||
return ( | ||
data[0], | ||
next(filter(lambda status: status[0] == data[1], status_choice)), | ||
) | ||
# # def filter_status(data, status_choice): | ||
# # return ( | ||
# # data[0], | ||
# # next(filter(lambda status: status[0] == data[1], status_choice)), | ||
# # ) | ||
|
||
|
||
result = list(map(lambda user: filter_status(user, STATUS_CHOICES), users)) | ||
# # result = list(map(lambda user: filter_status(user, STATUS_CHOICES), users)) | ||
|
||
print(result) | ||
# # print(result) | ||
|
||
# # 3 validção | ||
|
||
|
||
# class TransporteError(Exception): | ||
|
||
# def __init__(self, *args) -> None: | ||
# self.message = self.message = args[0] | ||
|
||
# # def __str__(self) -> str: | ||
# # return f"NotifyError, {self.message}" | ||
|
||
|
||
# def validar_cancelamento(data_agendada: datetime): | ||
|
||
# notification: dict[str, str] = {} | ||
|
||
# data_atual = datetime.now() | ||
|
||
# # data_atual = datetime(2024, 5, 25, 15, 30) | ||
|
||
# duration = data_atual - data_agendada | ||
|
||
# hora = data_atual.time().hour | ||
|
||
# if duration.days < 1: | ||
|
||
# raise TransporteError( | ||
# [ | ||
# "Ação não permitida por período limite excedito", | ||
# "O LIMITE PARA CANCELAMENTO É PERMITIDO COM UM DIA DE ANTECEDÊNCIA", | ||
# ], | ||
# ) | ||
|
||
# elif duration.days == 1 and hora >= 18: | ||
|
||
# raise TransporteError( | ||
# [ | ||
# "Ação não permitida por limite de horário", | ||
# "O CANCELAMENTO É PERMITIDO ATÉ ÀS 18HRS", | ||
# ], | ||
# ) | ||
|
||
# else: | ||
|
||
# return notification | ||
|
||
|
||
# try: | ||
|
||
# data_agendada = datetime(2024, 5, 25, 18, 25) | ||
|
||
# validar_cancelamento(data_agendada) | ||
|
||
# except TransporteError as exc: | ||
|
||
# print("exc>>>>>", exc.message) | ||
|
||
|
||
def calculate_value(input_value): | ||
# Perform calculations on the input value | ||
result = input_value * 2 | ||
return result | ||
|
||
|
||
# Example usage | ||
value = 10 | ||
calculated_value = calculate_value(value) | ||
|
||
print(calculated_value) # Output: 20 |