Skip to content

Commit b438349

Browse files
authored
fix: rephrasing and removing bugs from response endorsed notifications (#35136)
* fix: rephrasing and removing bugs from response endorsed notifications * test: updated test for response endorsed notifications
1 parent a935585 commit b438349

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

lms/djangoapps/discussion/rest_api/tasks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,16 @@ def send_response_endorsed_notifications(thread_id, response_id, course_key_str,
6060
if not ENABLE_NOTIFICATIONS.is_enabled(course_key):
6161
return
6262
thread = Thread(id=thread_id).retrieve()
63-
creator = User.objects.get(id=endorsed_by)
64-
course = get_course_with_access(creator, 'load', course_key, check_if_enrolled=True)
6563
response = Comment(id=response_id).retrieve()
64+
creator = User.objects.get(id=response.user_id)
65+
endorser = User.objects.get(id=endorsed_by)
66+
course = get_course_with_access(creator, 'load', course_key, check_if_enrolled=True)
6667
notification_sender = DiscussionNotificationSender(thread, course, creator)
6768
# skip sending notification to author of thread if they are the same as the author of the response
6869
if response.user_id != thread.user_id:
6970
# sends notification to author of thread
7071
notification_sender.send_response_endorsed_on_thread_notification()
7172
# sends notification to author of response
72-
if int(response.user_id) != creator.id:
73+
if int(response.user_id) != endorser.id:
7374
notification_sender.creator = User.objects.get(id=response.user_id)
7475
notification_sender.send_response_endorsed_notification()

lms/djangoapps/discussion/rest_api/tests/test_tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,10 @@ def test_response_endorsed_notifications(self):
600600
self.assertEqual(notification_data.notification_type, 'response_endorsed_on_thread')
601601

602602
expected_context = {
603-
'replier_name': self.user_3.username,
603+
'replier_name': self.user_2.username,
604604
'post_title': 'test thread',
605605
'course_name': self.course.display_name,
606-
'sender_id': int(self.user_3.id),
606+
'sender_id': int(self.user_2.id),
607607
}
608608
self.assertDictEqual(notification_data.context, expected_context)
609609
self.assertEqual(notification_data.content_url, _get_mfe_url(self.course.id, thread.id))

openedx/core/djangoapps/notifications/base_notification.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@
146146
'is_core': True,
147147
'info': '',
148148
'non_editable': [],
149-
'content_template': _('<{p}><{strong}>{replier_name}</{strong}> response has been endorsed in your post '
149+
'content_template': _('<{p}><{strong}>{replier_name}\'s</{strong}> response has been endorsed in your post '
150150
'<{strong}>{post_title}</{strong}></{p}>'),
151151
'content_context': {
152152
'post_title': 'Post title',
153-
'replier_name': 'Endorsed by',
153+
'replier_name': 'replier name',
154154
},
155155
'email_template': '',
156156
'filters': [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE]
@@ -161,7 +161,8 @@
161161
'is_core': True,
162162
'info': '',
163163
'non_editable': [],
164-
'content_template': _('<{p}><Your response has been endorsed <{strong}>{post_title}</{strong}></{p}>'),
164+
'content_template': _('<{p}>Your response has been endorsed on the post <{strong}>{post_title}</{strong}></{'
165+
'p}>'),
165166
'content_context': {
166167
'post_title': 'Post title',
167168
},

0 commit comments

Comments
 (0)