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_notification management 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
|
'default': { |
|
'level': 'info', |
|
'verb': 'default verb', |
|
'verbose_name': 'Default Type', |
|
'email_subject': '[{site.name}] Default Notification Subject', |
|
'message': ( |
|
'Default notification with {notification.verb} and level {notification.level}' |
|
' by [{notification.target}]({notification.target_link})' |
|
), |
|
'message_template': 'openwisp_notifications/default_message.md', |
|
'email_notification': True, |
|
'web_notification': True, |
|
}, |
- 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.
|
notification = Notification( |
|
recipient=recipient, |
|
actor=actor, |
|
verb=str(verb), |
|
public=public, |
|
description=description, |
|
timestamp=timestamp, |
|
level=level, |
|
type=notification_type, |
|
) |
Update the AbstractNotification model to use the verb from the configuration if database value is set to None
Describe the bug
The notification
verbis saved in the database. Thus, changing theverbin theNOTIFICATION_TYPEdoes not change the message of existing notifications.Steps To Reproduce
Steps to reproduce the behavior:
create_notificationmanagement command.openwisp-notifications/openwisp_notifications/types.py
Lines 7 to 19 in 55a3443
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.
openwisp-notifications/openwisp_notifications/handlers.py
Lines 139 to 148 in 55a3443
Update the AbstractNotification model to use the
verbfrom the configuration if database value is set to None