fix: prevent 500 error when course mode currency is not the same as the one configured in settings (#31312)

This commit solves the http 500 error when course concurrency is setted different for PAID_COURSE_REGISTRATION_CURRENCY and course modes.
This commit is contained in:
Henrry Pulgarin
2022-11-30 09:50:48 -05:00
committed by GitHub
parent 929d4b97d2
commit 93fd8cc148
2 changed files with 9 additions and 1 deletions

View File

@@ -774,7 +774,10 @@ class CourseMode(models.Model):
If there is no mode found, will return the price of DEFAULT_MODE, which is 0
"""
modes = cls.modes_for_course(course_id)
return min(mode.min_price for mode in modes if mode.currency.lower() == currency.lower())
return min(
(mode.min_price for mode in modes if mode.currency.lower() == currency.lower()),
default=0
)
@classmethod
def is_eligible_for_certificate(cls, mode_slug, status=None):