mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 17:59:11 -06:00
* Fixes #17097: Record static object representation when calling NotificationGroup.notify() * Redirect to notifications list when marking as read notifications for deleted objects * Link to object in notifications dropdown only for non-destructive events
This commit is contained in:
parent
b6071a80d9
commit
dd3166a4ed
@ -139,6 +139,7 @@ def process_event_rules(event_rules, object_type, event_type, data, username=Non
|
|||||||
event_rule.action_object.notify(
|
event_rule.action_object.notify(
|
||||||
object_type=object_type,
|
object_type=object_type,
|
||||||
object_id=data['id'],
|
object_id=data['id'],
|
||||||
|
object_repr=data.get('display'),
|
||||||
event_type=event_type
|
event_type=event_type
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -424,12 +424,17 @@ class NotificationReadView(LoginRequiredMixin, View):
|
|||||||
Mark the Notification read and redirect the user to its attached object.
|
Mark the Notification read and redirect the user to its attached object.
|
||||||
"""
|
"""
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
|
# Mark the Notification as read
|
||||||
notification = get_object_or_404(request.user.notifications, pk=pk)
|
notification = get_object_or_404(request.user.notifications, pk=pk)
|
||||||
notification.read = timezone.now()
|
notification.read = timezone.now()
|
||||||
notification.save()
|
notification.save()
|
||||||
|
|
||||||
|
# Redirect to the object if it has a URL (deleted objects will not)
|
||||||
|
if hasattr(notification.object, 'get_absolute_url'):
|
||||||
return redirect(notification.object.get_absolute_url())
|
return redirect(notification.object.get_absolute_url())
|
||||||
|
|
||||||
|
return redirect('account:notifications')
|
||||||
|
|
||||||
|
|
||||||
@register_model_view(Notification, 'dismiss')
|
@register_model_view(Notification, 'dismiss')
|
||||||
class NotificationDismissView(LoginRequiredMixin, View):
|
class NotificationDismissView(LoginRequiredMixin, View):
|
||||||
|
@ -7,7 +7,11 @@
|
|||||||
<i class="{{ notification.event.icon }}"></i>
|
<i class="{{ notification.event.icon }}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-truncate">
|
<div class="col text-truncate">
|
||||||
|
{% if not notification.event.destructive %}
|
||||||
<a href="{% url 'extras:notification_read' pk=notification.pk %}" class="text-body d-block">{{ notification.object_repr }}</a>
|
<a href="{% url 'extras:notification_read' pk=notification.pk %}" class="text-body d-block">{{ notification.object_repr }}</a>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-body d-block">{{ notification.object_repr }}</span>
|
||||||
|
{% endif %}
|
||||||
<div class="d-block text-secondary fs-5">{{ notification.event }} {{ notification.created|timesince }} {% trans "ago" %}</div>
|
<div class="d-block text-secondary fs-5">{{ notification.event }} {{ notification.created|timesince }} {% trans "ago" %}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
|
Loading…
Reference in New Issue
Block a user