diff --git a/netbox/extras/views.py b/netbox/extras/views.py index eacab2bcc..13f271329 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -409,22 +409,11 @@ class NotificationGroupBulkDeleteView(generic.BulkDeleteView): class NotificationsView(LoginRequiredMixin, View): def get(self, request): - notifications = Notification.objects.filter( - user=request.user, - read__isnull=True - ) return render(request, 'htmx/notifications.html', { - 'notifications': notifications, + 'notifications': request.user.notifications.unread(), + 'total_count': request.user.notifications.count(), }) - def post(self, request): - form = forms.RenderMarkdownForm(request.POST) - if not form.is_valid(): - HttpResponseBadRequest() - rendered = render_markdown(form.cleaned_data['text']) - - return HttpResponse(rendered) - @register_model_view(Notification, 'read') class NotificationReadView(LoginRequiredMixin, View): diff --git a/netbox/templates/htmx/notifications.html b/netbox/templates/htmx/notifications.html index 14d2f7130..c9230b81e 100644 --- a/netbox/templates/htmx/notifications.html +++ b/netbox/templates/htmx/notifications.html @@ -19,6 +19,10 @@ {% trans "No unread notifications" %} {% endfor %} + {% if total_count %} + + {% trans "All notifications" %} + {% badge total_count %} + + {% endif %} - -{% trans "All notifications" %}