Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [AXM-571] change texts in the push notifications #2569

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
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 %}
Loading