# HG changeset patch # User Brian Neal # Date 1411606416 18000 # Node ID 2c4f28b1c12a6e9e8b3d07b9e2d41f1acccc609f # Parent 71db8076dc3d503d4d1326af8fcabae47c0c559a Band map WIP: update admin dashboard for new band map entries. diff -r 71db8076dc3d -r 2c4f28b1c12a bandmap/models.py --- a/bandmap/models.py Tue Sep 23 20:40:31 2014 -0500 +++ b/bandmap/models.py Wed Sep 24 19:53:36 2014 -0500 @@ -7,6 +7,11 @@ from django.contrib.auth.models import User +class BandEntryManager(models.Manager): + def new_entry_count(self): + return self.filter(is_approved=False).count() + + class BandEntry(models.Model): """Represents a band entry on the band map.""" name = models.CharField(max_length=128) @@ -21,6 +26,8 @@ is_active = models.BooleanField(default=True, db_index=True) is_approved = models.BooleanField(default=False, db_index=True) + objects = BandEntryManager() + class Meta: ordering = ['name'] verbose_name_plural = 'band map entries' diff -r 71db8076dc3d -r 2c4f28b1c12a core/templatetags/custom_admin_tags.py --- a/core/templatetags/custom_admin_tags.py Tue Sep 23 20:40:31 2014 -0500 +++ b/core/templatetags/custom_admin_tags.py Wed Sep 24 19:53:36 2014 -0500 @@ -13,6 +13,7 @@ from weblinks.models import PendingLink, FlaggedLink from shoutbox.models import ShoutFlag from messages.models import Flag as PmFlag +from bandmap.models import BandEntry register = template.Library() @@ -37,6 +38,7 @@ broken_links = FlaggedLink.objects.count() flagged_shouts = ShoutFlag.objects.count() flagged_msgs = PmFlag.objects.count() + new_bands = BandEntry.objects.new_entry_count() return { 'user': user, @@ -50,4 +52,5 @@ 'broken_links': broken_links, 'flagged_shouts': flagged_shouts, 'flagged_msgs': flagged_msgs, + 'new_bands': new_bands, } diff -r 71db8076dc3d -r 2c4f28b1c12a sg101/templates/core/admin_dashboard.html --- a/sg101/templates/core/admin_dashboard.html Tue Sep 23 20:40:31 2014 -0500 +++ b/sg101/templates/core/admin_dashboard.html Wed Sep 24 19:53:36 2014 -0500 @@ -1,5 +1,5 @@ {% if user.is_staff %} -{% if flagged_posts or flagged_comments or flagged_profiles or event_requests or new_stories or new_downloads or new_links or flagged_shouts or broken_links or flagged_msgs %} +{% if flagged_posts or flagged_comments or flagged_profiles or event_requests or new_stories or new_downloads or new_links or flagged_shouts or broken_links or flagged_msgs or new_bands %} {% endif %} {% endif %}