Skip to content

Commit

Permalink
refactor: serializer code updated for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
eemaanamir authored and ayesha-waris committed Feb 6, 2024
1 parent a333283 commit 4f3d8bf
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions openedx/core/djangoapps/notifications/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,11 @@ def update(self, instance, validated_data):
value = validated_data.get('value')
user_notification_preference_config = instance.notification_preference_config

for notification_type_name, notification_type_preferences in user_notification_preference_config[
notification_app]['notification_types'].items():
if notification_type_name not in user_notification_preference_config[notification_app]['non_editable']:
user_notification_preference_config[notification_app]['notification_types'][notification_type_name][
notification_channel] = value
elif notification_channel not in user_notification_preference_config[notification_app]['non_editable'][
notification_type_name]:
user_notification_preference_config[notification_app]['notification_types'][notification_type_name][
notification_channel] = value
app_prefs = user_notification_preference_config[notification_app]
for notification_type_name, notification_type_preferences in app_prefs['notification_types'].items():
non_editable_channels = app_prefs['non_editable'].get(notification_type_name, [])
if notification_channel not in non_editable_channels:
app_prefs['notification_types'][notification_type_name][notification_channel] = value

instance.save()
return instance
Expand Down

0 comments on commit 4f3d8bf

Please sign in to comment.