[bug] Notification verb is saved in database
Describe the bug
The notification verb is saved in the database. Thus, changing the verb in the NOTIFICATION_TYPE does not change the message of existing notifications.
Steps To Reproduce Steps to reproduce the behavior:
- Create a default notification using the
create_notificationmanagement command. - Go to Django admin and verify the notification message.
Default notification with default verb and level info by default
- Change the verb for the default notification type https://github.com/openwisp/openwisp-notifications/blob/55a3443956f2ffa0301bd44a72d051f280fd02f7/openwisp_notifications/types.py#L7-L19
- Go to Django admin again and verify the notification message
Expected behavior The notification message should show the updated notification verb
Possible solution
Update the notify handler to not save the verb in the database.
https://github.com/openwisp/openwisp-notifications/blob/55a3443956f2ffa0301bd44a72d051f280fd02f7/openwisp_notifications/handlers.py#L139-L148
Update the AbstractNotification model to use the verb from the configuration if database value is set to None
Hey @pandafy, I think the solution approach is to make the verb field nullable, by updating the handler to make verb optional, and add a get_verb() method that prioritizes NOTIFICATION_TYPES config while falling back to the database value, with checking.. notifications properly reflect updated verbs while maintaining backward compatibility can solve this bug
can I give it a try ?
I kept the DB as fallback and made verb field nullable in the DB