From 2c4aaab4357de944904ccb5bca106180fd9f0905 Mon Sep 17 00:00:00 2001 From: echoduck Date: Oct 26 2018 21:01:58 +0000 Subject: Added packets sent counter to sidebar --- diff --git a/happinesspackets/messaging/context_processors.py b/happinesspackets/messaging/context_processors.py new file mode 100644 index 0000000..1c4672e --- /dev/null +++ b/happinesspackets/messaging/context_processors.py @@ -0,0 +1,5 @@ +from .models import Message + +def packets_sent_processor(request): + packets_sent = Message.objects.filter(status="sent").count() + return {'packets_sent': packets_sent} diff --git a/happinesspackets/settings/base.py b/happinesspackets/settings/base.py index db439e9..249badd 100644 --- a/happinesspackets/settings/base.py +++ b/happinesspackets/settings/base.py @@ -92,6 +92,7 @@ TEMPLATES = [ "django.template.context_processors.static", "django.template.context_processors.tz", "django.contrib.messages.context_processors.messages", + "happinesspackets.messaging.context_processors.packets_sent_processor", ], 'loaders': [ 'django.template.loaders.filesystem.Loader', diff --git a/templates/base.html b/templates/base.html index 92287b5..8752223 100644 --- a/templates/base.html +++ b/templates/base.html @@ -53,6 +53,7 @@ {% endif %} +

Packets sent: {{ packets_sent }}