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 2 commits into
base: main
Choose a base branch
from

Conversation

jonathanreveille
Copy link
Member

@jonathanreveille jonathanreveille commented Jan 29, 2025

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. They are either both set, or neither.

The start date cannot be greater than the end date.

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
src/backend/joanie/core/models/products.py Outdated Show resolved Hide resolved
Comment on lines 388 to 394
models.CheckConstraint(
check=~models.Q(start__isnull=True) ^ models.Q(end__isnull=True),
name="both_start_and_end_dates_must_be_set_or_neither",
violation_error_message=_(
"Both start and end dates must be set, or neither."
),
),
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we need this rule. We should talk bout it IRL.

Copy link
Member Author

Choose a reason for hiding this comment

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

as seen in IRL, we will take away this model constraint because we will use those fields for :

  • 🐦 early birds : set the end date only
  • last minute : set the beginning date only

Concerning the field is_active on OrderGroup model :

  • refer to is_active value in database if start nor end datetime are setted.
  • calculate through the OrderGroupSerializer and AdminOrderGroupSerializer the field is_active if either start or end or both datetimes are setted.

Copy link
Member Author

@jonathanreveille jonathanreveille Jan 31, 2025

Choose a reason for hiding this comment

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

REVIEWING COMMENT : (WIP)

...

  • 🐦 early birds : set the end date only (en fonction de la date d'ouverture et la date de fin du groupe)
  • last minute : set the beginning date only (en fonction de la date de cloture du cours)
    ...

@jonathanreveille jonathanreveille force-pushed the feat/add_start_and_end_date_to_ordergroup_model branch from 4b48e0b to b48a129 Compare January 30, 2025 18:18
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 from b48a129 to 5355f60 Compare January 30, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants