#57 Added packets sent counter to sidebar
Merged 5 years ago by algogator. Opened 5 years ago by echoduck.
fedora-commops/ echoduck/fedora-happiness-packets packets_sent  into  master

@@ -0,0 +1,5 @@ 

+ from .models import Message

+ 

+ def packets_sent_processor(request):

+     packets_sent = Message.objects.exclude(status="pending_sender_confirmation").count()

+     return {'packets_sent': packets_sent}

@@ -11,6 +11,25 @@ 

  from ..models import Message, BLACKLIST_HMAC_SALT, BlacklistedEmail

  

  

+ class MessageCounterTest(TestCase):

+     url = reverse('messaging:start')

+ 

+     def test_message_sent_included(self):

+         msg = MessageModelFactory(status="sent")

+         response = self.client.get(self.url)

+         self.assertContains(response,"Packets sent: <b>1</b>")

+ 

+     def test_message_read_included(self):

+         msg = MessageModelFactory(status="read")

+         response = self.client.get(self.url)

+         self.assertContains(response,"Packets sent: <b>1</b>")

+ 

+     def test_message_to_be_confirmed_excluded(self):

+         msg = MessageModelFactory(status="pending_sender_confirmation")

+         response = self.client.get(self.url)

+         self.assertContains(response,"Packets sent: <b>0</b>")

+ 

+ 

  class StartViewTest(TestCase):

      url = reverse('messaging:start')

  

@@ -92,6 +92,7 @@ 

                  "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',

file modified
+1
@@ -26,6 +26,7 @@ 

              {% url 'messaging:start' as url %}

              <a href="{{ url }}"><img src="{% static 'images/logo.png' %}" alt="Open-Source Happiness Packets" class="logo"/></a>

              <ul class="nav nav-stacked">

+                 <li><a>Packets sent: <b>{{ packets_sent }}</b></a></li>

                  {% url 'messaging:send' as url %}

                  <li role="presentation" {% if url in request.path %}class="active"{% endif %}><a href="{{ url }}">Send some happiness!</a></li>

                  {% url 'messaging:start' as url %}

Added a counter to the sidebar to keep track of how many packets have been sent.

Implements #46.

aw shucks i was gonna do it :) nontheless looks cool noice job <3

rebased onto 9ba1cabb8b0170488ff2e51ea2cfdb26225bd3cd

5 years ago

1 new commit added

  • Changed styling to be consistent with the rest of the sidebar, added tests, and added read messages to the counter.
5 years ago

rebased onto 2c4aaab

5 years ago

Pull-Request has been merged by algogator

5 years ago