Skip to content

Commit

Permalink
Updates the onclick for the instructor name to activate on keyup, fix…
Browse files Browse the repository at this point in the history
…es an issue with financial assistance page serialization (#2001)
  • Loading branch information
jkachel authored Nov 20, 2023
1 parent 7dc29df commit da67686
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cms/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def get_financial_assistance_form_url(self, instance):
.first()
)

if financial_assistance_page is None:
return ""

program_page = ProgramPage.objects.filter(
program=financial_assistance_page.selected_program
).get()
Expand Down
35 changes: 35 additions & 0 deletions cms/serializers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,38 @@ def test_serialize_program_page__no_financial_form(
"price": None,
},
)


def test_serialize_program_page__with_related_program_no_financial_form(
mocker, fully_configured_wagtail, staff_user, mock_context
):
fake_image_src = "http://example.com/my.img"
patched_get_wagtail_src = mocker.patch(
"cms.serializers.get_wagtail_img_src", return_value=fake_image_src
)

program = ProgramFactory(page=None)
program_page = ProgramPageFactory(program=program)
other_program = ProgramFactory(page=None)
other_program_page = ProgramPageFactory(program=other_program)
program.add_related_program(other_program)
rf = RequestFactory()
request = rf.get("/")
request.user = staff_user

data = ProgramPageSerializer(
instance=program_page, context=program_page.get_context(request)
).data
assert_drf_json_equal(
data,
{
"feature_image_src": fake_image_src,
"page_url": program_page.url,
"financial_assistance_form_url": "",
"description": bleach.clean(program_page.description, tags=[], strip=True),
"live": True,
"length": program_page.length,
"effort": program_page.effort,
"price": None,
},
)
4 changes: 2 additions & 2 deletions cms/templates/product_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h2>{{ page.faculty_section_title }}</h2>
<div class="member-card highlight-card" onClick="$('#instructor-modal-{{ member.id }}').modal('show');">
<img src="{% feature_img_src member.feature_image %}" alt="">
<div class="member-info">
<h3 id="instructor-name-{{ member.id }}" class="name" role="button" tabindex="0">
<h3 id="instructor-name-{{ member.id }}" class="name" role="button" tabindex="0" onClick="$('#instructor-modal-{{ member.id }}').modal('show');" onKeyUp="if (event.code === 'Enter') { $('#instructor-modal-{{ member.id }}').modal('show'); }">
{{ member.instructor_name }}
</h3>
{% if member.instructor_title %}<h4 class="title">{{ member.instructor_title }}</h4>{% endif %}
Expand Down Expand Up @@ -148,7 +148,7 @@ <h2>Who can take this course?</h2>

{% if instructors %}
{% for member in instructors %}
<div class="modal instructor-modal" tabindex="-1" id="instructor-modal-{{ member.id }}">
<div class="modal instructor-modal" tabindex="-1" id="instructor-modal-{{ member.id }}" data-keyboard="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
Expand Down

0 comments on commit da67686

Please sign in to comment.