Skip to content

[bug] Notification verb is saved in database #334

@pandafy

Description

@pandafy

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:

  1. Create a default notification using the create_notification management command.
  2. Go to Django admin and verify the notification message.
Default notification with default verb and level info by default
  1. 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,
    },
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    Status

    To do

    Status

    To do (Python & Django)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions