Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions openwisp_notifications/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ class AbstractNotification(UUIDModel, BaseNotification):
_action_object = BaseNotification.action_object
_target = BaseNotification.target

@property
def verb(self):
try:
config = get_notification_configuration(self.type)
return config.get("verb") or self.__dict__.get("verb") or "unspecified"
except Exception:
return self.__dict__.get("verb") or "unspecified"

@verb.setter
def verb(self, value):
self.__dict__["verb"] = value

class Meta(BaseNotification.Meta):
abstract = True

Expand Down
2 changes: 1 addition & 1 deletion openwisp_notifications/base/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AbstractNotification(models.Model):
actor = GenericForeignKey("actor_content_type", "actor_object_id")
actor.short_description = _("actor")

verb = models.CharField(_("verb"), max_length=255)
verb = models.CharField(_("verb"), max_length=255, null=True, blank=True)
description = models.TextField(_("description"), blank=True, null=True)

target_content_type = models.ForeignKey(
Expand Down
2 changes: 0 additions & 2 deletions openwisp_notifications/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def notify_handler(**kwargs):
level = kwargs.pop(
"level", notification_template.get("level", Notification.LEVELS.info)
)
verb = notification_template.get("verb", kwargs.pop("verb", None))
user_app_name = User._meta.app_label

where = Q(is_superuser=True)
Expand Down Expand Up @@ -146,7 +145,6 @@ def notify_handler(**kwargs):
notification = Notification(
recipient=recipient,
actor=actor,
verb=str(verb),
public=public,
description=description,
timestamp=timestamp,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.2.6 on 2025-10-01 09:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("openwisp_notifications", "0011_populate_organizationnotificationsettings"),
]

operations = [
migrations.AlterField(
model_name="notification",
name="verb",
field=models.CharField(max_length=255, null=True, blank=True),
),
]
Loading