Skip to content

Commit

Permalink
feat: [AXM-571] change texts in the push notifications (#2569)
Browse files Browse the repository at this point in the history
* feat: [AXM-571] change texts in the push notifications

* fix: [AXM-571] fix notifications to thread author
  • Loading branch information
NiedielnitsevIvan authored Jun 5, 2024
1 parent ed4db49 commit abe4feb
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions lms/djangoapps/discussion/signals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def create_message_context(comment, site):
'comment_body_text': comment.body_text,
'comment_author_id': comment.user_id,
'comment_created_at': comment.created_at, # comment_client models dates are already serialized
'comment_parent_id': comment.parent_id,
'thread_id': thread.id,
'thread_title': thread.title,
'thread_author_id': thread.user_id,
Expand Down
14 changes: 10 additions & 4 deletions lms/djangoapps/discussion/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,24 @@ def _should_send_message(context):
cc_thread_author = cc.User(id=context['thread_author_id'], course_id=context['course_id'])
return (
_is_user_subscribed_to_thread(cc_thread_author, context['thread_id']) and
_is_not_subcomment(context['comment_id'])
_is_not_subcomment(context['comment_id']) and
not _comment_author_is_thread_author(context)
)


def _should_send_subcomment_message(context):
cc_thread_author = cc.User(id=context['thread_author_id'], course_id=context['course_id'])
comment_author_is_thread_author = context['comment_author_id'] == context['thread_author_id']
return (
_is_user_subscribed_to_thread(cc_thread_author, context['thread_id']) and
_is_subcomment(context['comment_id']) and
not comment_author_is_thread_author
not _comment_author_is_thread_author(context)
)


def _comment_author_is_thread_author(context):
return context.get('comment_author_id', '') == context['thread_author_id']


def _is_content_still_reported(context):
if context.get('comment_id') is not None:
return len(cc.Comment.find(context['comment_id']).abuse_flaggers) > 0
Expand Down Expand Up @@ -262,8 +266,10 @@ def _build_message_context(context, notification_type='forum_comment'): # lint-
'comment_username': comment_author.username,
'post_link': post_link,
'push_notification_extra_context': {
'course_id': str(context['course_id']),
'parent_id': str(context['comment_parent_id']),
'notification_type': notification_type,
'topic_id': context.get('thread_commentable_id', ''),
'topic_id': str(context['thread_commentable_id']),
'thread_id': context['thread_id'],
'comment_id': context['comment_id'],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
{% load i18n %}
{% blocktrans trimmed %}{{ comment_username }} replied to {{ thread_title }}:{% endblocktrans %}
{{ comment_body_text }}
{% blocktrans trimmed %}{{ comment_username }} replied to {{ thread_title }}{% endblocktrans %}
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
{% load i18n %}

{% blocktrans %}Response to {{ thread_title }}{% endblocktrans %}
{% blocktrans %}Response to {{ thread_title }}{% endblocktrans %}
3 changes: 3 additions & 0 deletions lms/djangoapps/discussion/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def test_send_discussion_email_notification(self, user_subscribed):
'comment_body_text': comment.body_text,
'comment_created_at': ONE_HOUR_AGO,
'comment_id': comment['id'],
'comment_parent_id': comment['parent_id'],
'comment_username': self.comment_author.username,
'course_id': self.course.id,
'thread_author_id': self.thread_author.id,
Expand All @@ -292,6 +293,8 @@ def test_send_discussion_email_notification(self, user_subscribed):
'push_notification_extra_context': {
'notification_type': 'forum_response',
'topic_id': thread['commentable_id'],
'course_id': comment['course_id'],
'parent_id': str(comment['parent_id']),
'thread_id': thread['id'],
'comment_id': comment['id'],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear {{ full_name }}{% endblocktrans %}
{% blocktrans %}Dear {{ full_name }},{% endblocktrans %}
{% blocktrans %}You have been invited to be a beta tester for {{ course_name }} at {{ site_name }}.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}You have been invited to a beta test for {{ course_name }}{% endblocktrans %}
{% blocktrans %}You have been invited to a beta test for {{ course_name }} at {{ site_name }}.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear student,{% endblocktrans %}
{% blocktrans %}You have been invited to join {{ course_name }} at {{ site_name }}.{% endblocktrans %}
{% blocktrans %}You have been enrolled in {{ course_name }} at {{ site_name }}. This course will now appear on your {{ site_name }} dashboard.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}You have been invited to register for {{ course_name }}{% endblocktrans %}
{% blocktrans %}You have been invited to register for {{ course_name }}.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear {{ full_name }}{% endblocktrans %}
{% blocktrans %}Dear {{ full_name }},{% endblocktrans %}
{% blocktrans %}You have been unenrolled from {{ course_name }} at {{ site_name }}. This course will no longer appear on your {{ site_name }} dashboard.{% endblocktrans %}
{% endautoescape %}
4 changes: 2 additions & 2 deletions lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear {{ full_name }}{% endblocktrans %}
{% blocktrans %}You have been enrolled in {{ course_name }} at {{ site_name }}. This course will now appear on your {{ site_name }} dashboard.{% endblocktrans %}
{% blocktrans %}Dear {{ full_name }},{% endblocktrans %}
{% blocktrans %}You have been invited to join {{ course_name }} at {{ site_name }}.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear {{ full_name }}{% endblocktrans %}
{% blocktrans %}Dear {{ full_name }},{% endblocktrans %}
{% blocktrans %}You have been removed as a beta tester for {{ course_name }} at {{ site_name }}. This course will remain on your dashboard, but you will no longer be part of the beta testing group.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}You have been removed from a beta test for {{ course_name }}{% endblocktrans %}
{% blocktrans %}You have been removed as a beta tester for {{ course_name }} at {{ site_name }}.{% endblocktrans %}
{% endautoescape %}

0 comments on commit abe4feb

Please sign in to comment.