Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lms/djangoapps/discussion/rest_api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ def send_response_endorsed_notifications(thread_id, response_id, course_key_str,
if not ENABLE_NOTIFICATIONS.is_enabled(course_key):
return
thread = Thread(id=thread_id).retrieve()
creator = User.objects.get(id=endorsed_by)
course = get_course_with_access(creator, 'load', course_key, check_if_enrolled=True)
response = Comment(id=response_id).retrieve()
creator = User.objects.get(id=response.user_id)
endorser = User.objects.get(id=endorsed_by)
course = get_course_with_access(creator, 'load', course_key, check_if_enrolled=True)
notification_sender = DiscussionNotificationSender(thread, course, creator)
# skip sending notification to author of thread if they are the same as the author of the response
if response.user_id != thread.user_id:
# sends notification to author of thread
notification_sender.send_response_endorsed_on_thread_notification()
# sends notification to author of response
if int(response.user_id) != creator.id:
if int(response.user_id) != endorser.id:
notification_sender.creator = User.objects.get(id=response.user_id)
notification_sender.send_response_endorsed_notification()
4 changes: 2 additions & 2 deletions lms/djangoapps/discussion/rest_api/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,10 @@ def test_response_endorsed_notifications(self):
self.assertEqual(notification_data.notification_type, 'response_endorsed_on_thread')

expected_context = {
'replier_name': self.user_3.username,
'replier_name': self.user_2.username,
'post_title': 'test thread',
'course_name': self.course.display_name,
'sender_id': int(self.user_3.id),
'sender_id': int(self.user_2.id),
}
self.assertDictEqual(notification_data.context, expected_context)
self.assertEqual(notification_data.content_url, _get_mfe_url(self.course.id, thread.id))
Expand Down
7 changes: 4 additions & 3 deletions openedx/core/djangoapps/notifications/base_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@
'is_core': True,
'info': '',
'non_editable': [],
'content_template': _('<{p}><{strong}>{replier_name}</{strong}> response has been endorsed in your post '
'content_template': _('<{p}><{strong}>{replier_name}\'s</{strong}> response has been endorsed in your post '
'<{strong}>{post_title}</{strong}></{p}>'),
'content_context': {
'post_title': 'Post title',
'replier_name': 'Endorsed by',
'replier_name': 'replier name',
},
'email_template': '',
'filters': [FILTER_AUDIT_EXPIRED_USERS_WITH_NO_ROLE]
Expand All @@ -161,7 +161,8 @@
'is_core': True,
'info': '',
'non_editable': [],
'content_template': _('<{p}><Your response has been endorsed <{strong}>{post_title}</{strong}></{p}>'),
'content_template': _('<{p}>Your response has been endorsed on the post <{strong}>{post_title}</{strong}></{'
'p}>'),
'content_context': {
'post_title': 'Post title',
},
Expand Down