Skip to content

Commit 9f255df

Browse files
committed
revert: Remove code for group new comment notification
1 parent 27d03cb commit 9f255df

File tree

4 files changed

+3
-95
lines changed

4 files changed

+3
-95
lines changed

openedx/core/djangoapps/notifications/base_notification.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
'is_core': True,
3232
'content_template': _('<{p}><{strong}>{replier_name}</{strong}> commented on <{strong}>{author_name}'
3333
'</{strong}> response to your post <{strong}>{post_title}</{strong}></{p}>'),
34-
'grouped_content_template': _('<{p}><{strong}>{replier_name}</{strong}> commented on <{strong}>{author_name}'
35-
'</{strong}> response to your post <{strong}>{post_title}</{strong}></{p}>'),
3634
'content_context': {
3735
'post_title': 'Post title',
3836
'author_name': 'author name',

openedx/core/djangoapps/notifications/grouping_notifications.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,6 @@ def get_grouper(cls, notification_type: str) -> Union[BaseNotificationGrouper, N
6363
return grouper_class()
6464

6565

66-
@NotificationRegistry.register('new_comment')
67-
class NewCommentGrouper(BaseNotificationGrouper):
68-
"""
69-
Groups new comment notifications based on the replier name.
70-
"""
71-
72-
def group(self, new_notification, old_notification):
73-
"""
74-
Groups new comment notifications based on the replier name.
75-
"""
76-
context = old_notification.content_context.copy()
77-
if not context.get('grouped'):
78-
context['replier_name_list'] = [context['replier_name']]
79-
context['grouped_count'] = 1
80-
context['grouped'] = True
81-
context['replier_name_list'].append(new_notification.content_context['replier_name'])
82-
context['grouped_count'] += 1
83-
context['email_content'] = new_notification.content_context.get('email_content', '')
84-
return context
85-
86-
8766
@NotificationRegistry.register('new_discussion_post')
8867
class NewPostGrouper(BaseNotificationGrouper):
8968
"""

openedx/core/djangoapps/notifications/notification_content.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,7 @@ def get_notification_context_with_author_pronoun(context: Dict) -> Dict:
3131

3232

3333
# Returns notification content for the new_comment notification.
34-
def get_new_comment_notification_context(context):
35-
"""
36-
Returns the context for the new_comment notification
37-
"""
38-
if not context.get('grouped'):
39-
return get_notification_context_with_author_pronoun(context)
40-
num_repliers = context['grouped_count']
41-
repliers_string = f"{num_repliers - 1} other{'s' if num_repliers > 2 else ''}"
42-
context['replier_name'] = f"{context['replier_name_list'][0]} and {repliers_string}"
43-
return context
34+
get_new_comment_notification_context = get_notification_context_with_author_pronoun
4435

4536

4637
# Returns notification content for the comment_on_followed_post notification.

openedx/core/djangoapps/notifications/tests/test_notification_grouping.py

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from openedx.core.djangoapps.notifications.grouping_notifications import (
1313
BaseNotificationGrouper,
1414
NotificationRegistry,
15-
NewCommentGrouper,
1615
group_user_notifications,
1716
get_user_existing_notifications, NewPostGrouper
1817
)
@@ -47,65 +46,6 @@ def test_get_grouper_returns_none_for_unregistered_type(self):
4746
self.assertIsNone(grouper)
4847

4948

50-
class TestNewCommentGrouper(unittest.TestCase):
51-
"""
52-
Tests for the NewCommentGrouper class
53-
"""
54-
55-
def setUp(self):
56-
"""
57-
Set up the test
58-
"""
59-
self.new_notification = MagicMock(spec=Notification)
60-
self.old_notification = MagicMock(spec=Notification)
61-
self.old_notification.content_context = {
62-
'replier_name': 'User1'
63-
}
64-
65-
def test_group_creates_grouping_keys(self):
66-
"""
67-
Test that the function creates the grouping keys
68-
"""
69-
updated_context = NewCommentGrouper().group(self.new_notification, self.old_notification)
70-
71-
self.assertIn('replier_name_list', updated_context)
72-
self.assertIn('grouped_count', updated_context)
73-
self.assertEqual(updated_context['grouped_count'], 2)
74-
self.assertTrue(updated_context['grouped'])
75-
76-
def test_group_appends_to_existing_grouping(self):
77-
"""
78-
Test that the function appends to the existing grouping
79-
"""
80-
# Mock a pre-grouped notification
81-
self.old_notification.content_context = {
82-
'replier_name': 'User1',
83-
'replier_name_list': ['User1', 'User2'],
84-
'grouped': True,
85-
'grouped_count': 2
86-
}
87-
self.new_notification.content_context = {'replier_name': 'User3'}
88-
89-
updated_context = NewCommentGrouper().group(self.new_notification, self.old_notification)
90-
91-
self.assertIn('replier_name_list', updated_context)
92-
self.assertEqual(len(updated_context['replier_name_list']), 3)
93-
self.assertEqual(updated_context['grouped_count'], 3)
94-
95-
def test_group_email_content(self):
96-
"""
97-
Tests email_content in content_context when grouping notification
98-
"""
99-
self.old_notification.content_context['email_content'] = 'old content'
100-
self.new_notification.content_context = {
101-
'email_content': 'new content',
102-
'replier_name': 'user_2',
103-
}
104-
content_context = NewCommentGrouper().group(self.new_notification, self.old_notification)
105-
self.assertIn('email_content', content_context)
106-
self.assertEqual(content_context['email_content'], 'new content')
107-
108-
10949
class TestNewPostGrouper(unittest.TestCase):
11050
"""
11151
Tests for the NewPostGrouper class
@@ -159,7 +99,7 @@ def test_group_user_notifications(self, mock_get_grouper):
15999
Test that the function groups notifications using the appropriate grou
160100
"""
161101
# Mock the grouper
162-
mock_grouper = MagicMock(spec=NewCommentGrouper)
102+
mock_grouper = MagicMock(spec=NewPostGrouper)
163103
mock_get_grouper.return_value = mock_grouper
164104

165105
new_notification = MagicMock(spec=Notification)
@@ -237,7 +177,7 @@ def test_get_user_existing_notifications(self, mock_filter):
237177
mock_filter.return_value = [mock_notification1, mock_notification2]
238178

239179
user_ids = [1, 2]
240-
notification_type = 'new_comment'
180+
notification_type = 'new_discussion_post'
241181
group_by_id = 'group_id_1'
242182
course_id = 'course_1'
243183

0 commit comments

Comments
 (0)