Skip to content

Conversation

@mbertrand
Copy link
Member

@mbertrand mbertrand commented Oct 24, 2024

What are the relevant tickets?

PR 2 of 5 to address https://github.com/mitodl/hq/issues/5134 and https://github.com/mitodl/hq/issues/4685

Dependent on PR 1 here: #1736

Description (What does it do?)

  • Updates the front end to use the resource_prices field and display the correct currency symbol.
  • Adds a new JS package currency-symbol-map to display the correct symbol for the currency.

Screenshots (if appropriate):

If price is in Euros (EUR):
Screenshot 2024-10-23 at 1 05 50 PM

If price is in Swiss francs (CHF, no symbol):

Screenshot 2024-10-23 at 1 03 54 PM

In dollars (USD):
Screenshot 2024-10-23 at 1 07 46 PM

How can this be tested?

  • If you don't already have some courses with prices, run these commands on the main branch:
    ./manage.py backpopulate_mitxonline_data
    ./manage.py backpopulate_xpro_data
    ./manage.py backpopulate_sloan_data
    
  • Log in as an admin user to avoid caching and go to http://open.odl.local:8062/search?platform=mitxonline&platform=xpro, you will see a mix of courses that should all either be paid with certificate (xpro) or free with a paid certificate option (mitxonline). If you click on a course card you will see the same price in the drawer.
  • You can test the currency by running this code:
    from learning_resources.models import LearningResource
    from learning_resources.utils import resource_upserted_actions
    resource = LearningResource.objects.get(title="Applying Machine Learning to Engineering and Science")
    resource.resource_prices.all().update(currency="EUR")
    resource_upserted_actions(resource, False)
  • Now wait a minute then go to http://open.odl.local:8062/search?q=%22Applying+Machine+Learning%22 - the price of the top result should show the euro symbol €1559 instead of $1559 on the course card and resource drawer.
  • Also go to http://open.odl.local:8062/search?q=%22Driving+Strategic+Innovation%22 - the first result should have a price of "CHF 12500" (Swiss francs, which don't have a symbol).
  • Check and uncheck the "Free" checkbox on the search page. The results should change as expected.

Additional Context

  • There will be 3 subsequent PR's before https://github.com/mitodl/hq/issues/5134 is closed:
    • 3: Modify the LearningResource.prices and LearningResourceRun.prices fields to be the same as resource_prices, and update schema. (Note: this will cause index updates to fail until a reindex completes)
    • 4: Change frontend to use prices field again
    • 5: Remove resource_prices from models and schemas.

@mbertrand mbertrand changed the base branch from main to mb/price_model_01 October 24, 2024 15:51
@mbertrand mbertrand added the Needs Review An open Pull Request that is ready for review label Oct 24, 2024
@mbertrand mbertrand force-pushed the mb/price_model_01 branch 3 times, most recently from 94b6e25 to 5384a05 Compare October 28, 2024 11:59
@mbertrand mbertrand changed the base branch from mb/price_model_01 to main October 30, 2024 15:46
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

Log in as an admin user to avoid caching and go to

Missed that and was confused for a while. 🤦

@mbertrand mbertrand merged commit e460daa into main Oct 31, 2024
11 checks passed
@rhysyngsun rhysyngsun deleted the mb/price_model_02 branch February 7, 2025 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants