Check to make sure the end date and upgrade deadline haven't passed before grabbing your audit enrollment #2044
+85
−41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
Closes mitodl/hq#3295
Description (What does it do?)
If you have an existing enrollment in a course that is upgradeable, the enroll now button component will try to funnel you into upgrading that enrollment. However, it did this funneling even if the run's deadline had passed. This fixes that by adding some checks to make sure the course run is actually eligible for upgrade.
How can this be tested?
Set up two course runs (and related course, if necessary). One should be fully in the past and one should be eligible for enrollment and upgrade now. The course runs must have products and the course must have a CMS page. Create an audit enrollment in the past course run, then load the course page. You should see the normal messaging - current upgrade deadline and price, Enroll Now button - and clicking Enroll Now should prompt you to upgrade into the new course.