Skip to content

Commit

Permalink
chore: provide logo url from backend for batch enrollment email (#35138)
Browse files Browse the repository at this point in the history
* chore: provide logo url from backend for batch enrollment email
  • Loading branch information
mudassir-hafeez authored Aug 26, 2024
1 parent 66f3a08 commit 353dc34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lms/djangoapps/instructor/enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
get_event_transaction_id,
set_event_transaction_type
)
from lms.djangoapps.branding.api import get_logo_url_for_email
from lms.djangoapps.courseware.models import StudentModule
from lms.djangoapps.grades.api import constants as grades_constants
from lms.djangoapps.grades.api import disconnect_submissions_signal_receiver
Expand Down Expand Up @@ -489,6 +490,7 @@ def get_email_params(course, auto_enroll, secure=True, course_key=None, display_
'contact_mailing_address': contact_mailing_address,
'platform_name': platform_name,
'site_configuration_values': configuration_helpers.get_current_site_configuration_values(),
'logo_url': get_logo_url_for_email(),
}
return email_params

Expand Down
16 changes: 16 additions & 0 deletions lms/djangoapps/instructor/tests/test_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from common.djangoapps.student.models import CourseEnrollment, CourseEnrollmentAllowed, anonymous_id_for_user
from common.djangoapps.student.roles import CourseCcxCoachRole
from common.djangoapps.student.tests.factories import AdminFactory, UserFactory
from lms.djangoapps.branding.api import get_logo_url_for_email
from lms.djangoapps.ccx.tests.factories import CcxFactory
from lms.djangoapps.course_blocks.api import get_course_blocks
from lms.djangoapps.courseware.models import StudentModule
Expand Down Expand Up @@ -940,6 +941,7 @@ def setUpClass(cls):
)
cls.course_about_url = cls.course_url + 'about'
cls.registration_url = f'https://{site}/register'
cls.logo_url = get_logo_url_for_email()

def test_normal_params(self):
# For a normal site, what do we expect to get for the URLs?
Expand All @@ -950,6 +952,7 @@ def test_normal_params(self):
assert result['course_about_url'] == self.course_about_url
assert result['registration_url'] == self.registration_url
assert result['course_url'] == self.course_url
assert result['logo_url'] == self.logo_url

def test_marketing_params(self):
# For a site with a marketing front end, what do we expect to get for the URLs?
Expand All @@ -962,6 +965,19 @@ def test_marketing_params(self):
assert result['course_about_url'] is None
assert result['registration_url'] == self.registration_url
assert result['course_url'] == self.course_url
assert result['logo_url'] == self.logo_url

@patch('lms.djangoapps.instructor.enrollment.get_logo_url_for_email', return_value='https://www.logo.png')
def test_logo_url_params(self, mock_get_logo_url_for_email):
# Verify that the logo_url is correctly set in the email params
result = get_email_params(self.course, False)

assert result['auto_enroll'] is False
assert result['course_about_url'] == self.course_about_url
assert result['registration_url'] == self.registration_url
assert result['course_url'] == self.course_url
mock_get_logo_url_for_email.assert_called_once()
assert result['logo_url'] == 'https://www.logo.png'


@ddt.ddt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<tr>
<td width="70">
<a href="{% with_link_tracking homepage_url %}"><img
src="http://localhost:18000/static/red-theme/images/logo.png"
src="{{ logo_url }}"
alt="{% filter force_escape %} {% blocktrans %}Go to {{ platform_name }} Home Page{% endblocktrans %} {% endfilter %}"/></a>
</td>
<td align="right" style="text-align: {{ LANGUAGE_BIDI|yesno:"left,right" }};">
Expand Down

0 comments on commit 353dc34

Please sign in to comment.