Skip to content

Commit

Permalink
feat: removed setting email cadence to Never when using one click uns…
Browse files Browse the repository at this point in the history
…ubscribe (openedx#35708)
  • Loading branch information
muhammadadeeltajamul authored Oct 28, 2024
1 parent ebe3dc5 commit e1f31fb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
13 changes: 3 additions & 10 deletions openedx/core/djangoapps/notifications/email/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
COURSE_NOTIFICATION_TYPES,
)
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_EMAIL_NOTIFICATIONS
from openedx.core.djangoapps.notifications.email_notifications import EmailCadence
from openedx.core.djangoapps.notifications.models import CourseNotificationPreference, Notification
from openedx.core.djangoapps.notifications.email.utils import (
add_additional_attributes_to_notifications,
Expand Down Expand Up @@ -320,9 +319,7 @@ def test_value_with_channel_param(self, param_channel, new_value):
if channel == param_channel:
assert type_prefs[channel] == new_value
if channel == 'email':
cadence_value = EmailCadence.NEVER
if new_value:
cadence_value = self.get_default_cadence_value(app_name, noti_type)
cadence_value = self.get_default_cadence_value(app_name, noti_type)
assert type_prefs['email_cadence'] == cadence_value
else:
default_app_json = self.default_json[app_name]
Expand Down Expand Up @@ -381,9 +378,7 @@ def test_value_with_app_name_param(self, param_app_name, new_value):
if app_name == param_app_name:
assert type_prefs[channel] == new_value
if channel == 'email':
cadence_value = EmailCadence.NEVER
if new_value:
cadence_value = self.get_default_cadence_value(app_name, noti_type)
cadence_value = self.get_default_cadence_value(app_name, noti_type)
assert type_prefs['email_cadence'] == cadence_value
else:
default_app_json = self.default_json[app_name]
Expand Down Expand Up @@ -415,9 +410,7 @@ def test_value_with_notification_type_param(self, param_notification_type, new_v
if noti_type == param_notification_type:
assert type_prefs[channel] == new_value
if channel == 'email':
cadence_value = EmailCadence.NEVER
if new_value:
cadence_value = self.get_default_cadence_value(app_name, noti_type)
cadence_value = self.get_default_cadence_value(app_name, noti_type)
assert type_prefs['email_cadence'] == cadence_value
else:
default_app_json = self.default_json[app_name]
Expand Down
6 changes: 2 additions & 4 deletions openedx/core/djangoapps/notifications/email/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@ def get_updated_preference(pref):
continue
if is_editable(app_name, noti_type, channel):
type_prefs[channel] = pref_value
if channel == 'email':
cadence_value = get_default_cadence_value(app_name, noti_type)\
if pref_value else EmailCadence.NEVER
type_prefs['email_cadence'] = cadence_value
if channel == 'email' and pref_value and type_prefs.get('email_cadence') == EmailCadence.NEVER:
type_prefs['email_cadence'] = get_default_cadence_value(app_name, noti_type)
preference.save()
notification_preference_unsubscribe_event(user)
2 changes: 0 additions & 2 deletions openedx/core/djangoapps/notifications/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
FORUM_ROLE_MODERATOR
)
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS
from openedx.core.djangoapps.notifications.email_notifications import EmailCadence
from openedx.core.djangoapps.notifications.models import (
CourseNotificationPreference,
Notification,
Expand Down Expand Up @@ -936,7 +935,6 @@ def test_if_preference_is_updated(self, request_type):
for app_name, app_prefs in config.items():
for type_prefs in app_prefs['notification_types'].values():
assert type_prefs['email'] is False
assert type_prefs['email_cadence'] == EmailCadence.NEVER

def test_if_config_version_is_updated(self):
"""
Expand Down

0 comments on commit e1f31fb

Please sign in to comment.