Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (44 sloc) 1.72 KB
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth.models import User
from pinax.apps.tribes.models import Tribe
_inbox_count_sources = None
def inbox_count_sources():
global _inbox_count_sources
if _inbox_count_sources is None:
sources = []
for path in settings.COMBINED_INBOX_COUNT_SOURCES:
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
mod = __import__(module, {}, {}, [attr])
except ImportError, e:
raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))
func = getattr(mod, attr)
except AttributeError:
raise ImproperlyConfigured('Module "%s" does not define a "%s" callable request processor' % (module, attr))
_inbox_count_sources = tuple(sources)
return _inbox_count_sources
def combined_inbox_count(request):
A context processor that uses other context processors defined in
setting.COMBINED_INBOX_COUNT_SOURCES to return the combined number from
arbitrary counter sources.
count = 0
for func in inbox_count_sources():
counts = func(request)
if counts:
for value in counts.itervalues():
count = count + int(value)
except (TypeError, ValueError):
return {'combined_inbox_count': count,}
def footer(request):
return {
'latest_tribes': Tribe.objects.all().order_by('-created')[:5],
'latest_users': User.objects.all().order_by('-date_joined')[:9],