Skip to content

[bug] User notification preferences page throws error after removing notification type and repopulating preferences #426

@pandafy

Description

@pandafy

Describe the bug
The populate_notification_preferences command does not delete the NotifiationSettings for undefined Notification Types, instead it flags them as deleted.

The REST API endpoint does not exclude the deleted NotificationSetting objects. Thus, opening the notification preferences page raises NotificationRenderException.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Ensure there's a superuser created in your project
  2. Add a new notification type in openwisp_notifications/apps.py using the register_notification_type method
  3. Run ./manage.py populate_notification_preferences command
  4. Remove the code which adds the new notification type
  5. Run ./manage.py populate_notification_preferences command which is supposed to delete NotificationSettings for undefined notification types.
  6. Run django server and go to the user's notification preferences page

Expected behavior
User notification preferences are displayed.

Actual result
No notification preference is displayed. The application shows Error fetching notification settings. Please try again.

Other Notes

This bug was found while upgrading OpenWISP Controller from 1.1 to 1.2 (the api_task_error and api_task_recovery notification types were removed in openwisp-controller). Thus, the solution should also be tested manually with OpenWISP controller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    To do (Python & Django)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions