From cd51248a6c472597fb5548d9b8b5416ef64c8ccc Mon Sep 17 00:00:00 2001 From: Alireza Zare <78508222+azare242@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:56:22 +0330 Subject: [PATCH] feat: Close event register in 1 hour before start (#63) --- backend/backend_api/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/backend_api/models.py b/backend/backend_api/models.py index d998ca4..a89178b 100644 --- a/backend/backend_api/models.py +++ b/backend/backend_api/models.py @@ -451,6 +451,10 @@ def create_payment_for_user(user: User, discount: Discount): raise ValidationError( new_detailed_response(status.HTTP_400_BAD_REQUEST, f"Workshop {workshop.id} is full")) + if workshop.start_date - timezone.now() <= timezone.timedelta(hours=1): + raise ValidationError(new_detailed_response( + status.HTTP_400_BAD_REQUEST, f"Workshop {workshop.id} Registraition closed" + )) total_cost += workshop.cost workshops.append(workshop) except ObjectDoesNotExist: @@ -465,6 +469,11 @@ def create_payment_for_user(user: User, discount: Discount): raise ValidationError( new_detailed_response(status.HTTP_400_BAD_REQUEST, f"Presentation {presentation.id} is full")) + + if presentation.start_date - timezone.now() <= timezone.timedelta(hours=1): + raise ValidationError(new_detailed_response( + status.HTTP_400_BAD_REQUEST, f"Workshop {presentation.id} Participation closed" + )) total_cost += presentation.cost presentations.append(presentation) except ObjectDoesNotExist: