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

✨(backend) add start and end date on OrderGroup model #1032

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jonathanreveille
Copy link
Member

@jonathanreveille jonathanreveille commented Jan 29, 2025

This pull request will solve this issue.

We want to be able to define a start and end date on order groups. This will allow us to use them as promotional periods such as : early bird, last minute or promotional sales.

Here is the logic applied :

  • The order group has is_active set to False: we don’t calculate anything, we return False (value in db).
  • The order group has is_active set to True and no date is defined: we return True (value in db).
  • Early bird: The group has is_active set to True, but the current date is not within the interval between the start of course_run.enrollment_start and the date of order_group.end: we return False. If it is within the interval, we return True.
  • Last minute: The group has is_active set to True, but the current date is not within the interval between the start of course_run.enrollment_end and the date of order_group.start: we return False. If it is within the interval, we return True.
  • Discounted price promotion: The group has is_active set to True, and the current date is within the interval: we return True. If the date is not within the interval, we return False.
    Only when is_active is set to True do we determine whether it is enabled or not.
    The above conditions should also take into account whether there are still available seats in the order group.

Proposal

  • add new fields start and end datetime fields on OrderGroup model

@jonathanreveille jonathanreveille self-assigned this Jan 29, 2025
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch 2 times, most recently from 900f92a to b844aa3 Compare January 29, 2025 17:14
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch 2 times, most recently from b48a129 to 5355f60 Compare January 30, 2025 18:18
src/backend/joanie/core/serializers/admin.py Outdated Show resolved Hide resolved
src/backend/joanie/core/utils/ordergroup.py Outdated Show resolved Hide resolved
src/backend/joanie/core/utils/ordergroup.py Outdated Show resolved Hide resolved
src/backend/joanie/core/serializers/client.py Outdated Show resolved Hide resolved
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch 9 times, most recently from 1da6d5b to a3c4153 Compare February 4, 2025 15:41
@jonathanreveille jonathanreveille changed the title ✨(backend) add start and end date on OrderGroup model ✨(backend) add start and end date on OrderGroup model Feb 4, 2025
src/backend/joanie/core/serializers/client.py Outdated Show resolved Hide resolved
src/backend/joanie/core/serializers/admin.py Outdated Show resolved Hide resolved
src/backend/joanie/tests/core/test_models_order_group.py Outdated Show resolved Hide resolved
src/backend/joanie/core/models/products.py Outdated Show resolved Hide resolved
src/backend/joanie/core/models/products.py Outdated Show resolved Hide resolved
src/backend/joanie/core/models/products.py Outdated Show resolved Hide resolved
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch 7 times, most recently from 3489399 to 2691264 Compare February 5, 2025 10:24
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch 6 times, most recently from 356a85c to b5ca298 Compare February 5, 2025 17:34
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch 5 times, most recently from 6a96e10 to 3aa2362 Compare February 6, 2025 11:11
src/backend/joanie/core/models/products.py Outdated Show resolved Hide resolved
src/backend/joanie/tests/core/test_models_order_group.py Outdated Show resolved Hide resolved
src/backend/joanie/tests/core/test_models_order_group.py Outdated Show resolved Hide resolved
src/backend/joanie/tests/core/test_models_order_group.py Outdated Show resolved Hide resolved
src/backend/joanie/tests/core/test_models_order_group.py Outdated Show resolved Hide resolved
src/backend/joanie/tests/core/test_models_order_group.py Outdated Show resolved Hide resolved
src/backend/joanie/core/models/products.py Outdated Show resolved Hide resolved
src/backend/joanie/core/serializers/admin.py Outdated Show resolved Hide resolved
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch from 3aa2362 to b8310ee Compare February 6, 2025 13:17
We want to be able to define a starting and ending date
on order groups. This will allow to use them as promotional
sessions on a given course with a fix number of available
seats. For now, order groups work just as before, but if
you define a starting date, you should define also an
ending date of validity.
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch 2 times, most recently from 1fd8c49 to 6339b81 Compare February 6, 2025 18:05
@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch from 6339b81 to 371e71a Compare February 7, 2025 09:57
@@ -379,6 +381,28 @@ class OrderGroup(BaseModel):
on_delete=models.CASCADE,
)
is_active = models.BooleanField(_("is active"), default=True)
# Available start to end period of activation of the OrderGroup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Available start to end period of activation of the OrderGroup

@@ -379,6 +381,28 @@ class OrderGroup(BaseModel):
on_delete=models.CASCADE,
)
is_active = models.BooleanField(_("is active"), default=True)
# Available start to end period of activation of the OrderGroup
start = models.DateTimeField(
help_text=_("order group’s start date and time"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like this ?

Suggested change
help_text=_("order group’s start date and time"),
help_text=_("Date at which the order group activation begins"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants