mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 16:48:16 -06:00
Include total notification count in dropdown
This commit is contained in:
parent
29675d6e45
commit
1c8118304f
@ -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):
|
||||
|
@ -19,6 +19,10 @@
|
||||
{% trans "No unread notifications" %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if total_count %}
|
||||
<a href="{% url 'account:notifications' %}" class="list-group-item list-group-item-action d-flex justify-content-between p-2">
|
||||
{% trans "All notifications" %}
|
||||
{% badge total_count %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<hr class="dropdown-divider" />
|
||||
<a href="{% url 'account:notifications' %}" class="dropdown-item">{% trans "All notifications" %}</a>
|
||||
|
Loading…
Reference in New Issue
Block a user