chore: move the credit button href to backend (#36930)

* chore: move the credit button href to backend

* refactor: quality checks

---------

Co-authored-by: Muhammad Noyan  Aziz <noyan.aziz@A006-01474.local>
This commit is contained in:
Muhammad Noyan Aziz
2025-06-25 10:35:51 +05:00
committed by GitHub
parent 2c2721436d
commit 8ede4a2ee7
2 changed files with 11 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ from opaque_keys.edx.keys import CourseKey
from openedx_filters.learning.filters import DashboardRenderStarted
from pytz import UTC
from edx_django_utils.plugins import pluggable_override
from lms.djangoapps.bulk_email.api import is_bulk_email_feature_enabled
from lms.djangoapps.bulk_email.models import Optout
from common.djangoapps.course_modes.models import CourseMode
@@ -323,6 +324,14 @@ def reverification_info(statuses):
return reverifications
@pluggable_override('OVERRIDE_GET_CREDIT_BUTTON_HREF')
def get_credit_button_href(course_key):
"""
Get the credit button URL for a course.
"""
return f"{settings.ECOMMERCE_PUBLIC_URL_ROOT}/credit/checkout/{course_key}/"
def credit_statuses(user, course_enrollments):
"""
Retrieve the status for credit courses.
@@ -423,6 +432,7 @@ def credit_statuses(user, course_enrollments):
"provider_id": None,
"request_status": request_status_by_course.get(course_key),
"error": False,
"credit_btn_href": get_credit_button_href(str(course_key)),
}
# If the user has purchased credit, then include information about the credit

View File

@@ -24,10 +24,7 @@
credit_msg_class = "credit-eligibility-msg"
credit_btn_class = "purchase-credit-btn"
credit_btn_label = _("Get Credit")
ecommerce_url_root = static.get_value('ECOMMERCE_PUBLIC_URL_ROOT', settings.ECOMMERCE_PUBLIC_URL_ROOT)
credit_btn_href = '{root}/credit/checkout/{course_id}/'.format(
root=ecommerce_url_root,
course_id=credit_status['course_key'])
credit_btn_href = credit_status['credit_btn_href']
if credit_status["purchased"]:
request_status = credit_status["request_status"]