fixes the report count at the top of each page

This commit is contained in:
Nathan Dinsmore 2013-01-15 17:12:05 -05:00
parent 83094b2b7e
commit 3b8f6222da
3 changed files with 11 additions and 10 deletions

View file

@ -43,9 +43,11 @@
{% else %}
<li>{% trans "You are not logged in." %}</li>
{% endif %}
{% if user.is_superuser or can_view_reports %}
<li class="reportlink"><strong><a href="{% url djangobb:forum_reports %}">{% trans "There are new reports" %} ({% new_reports %})</a></strong></li>
{% endif %}
{% with user|forum_reports as report_count %}
{% if report_count %}
<li class="reportlink"><strong><a href="{% url djangobb:forum_reports %}">{% blocktrans %}There are new reports ({{ report_count }}){% endblocktrans %}</a></strong></li>
{% endif %}
{% endwith %}
</ul>
{% if user.is_authenticated %}
<ul class="conr">

View file

@ -35,6 +35,11 @@ def forum_time(time):
return u'%s %s' % (capfirst(naturalday(time)), time.strftime('%H:%M:%S'))
@register.filter
def forum_reports(user):
return Report.objects.filter(zapped=False).count() if user.is_superuser or user.has_perm('djangobb_forum.change_report') else 0
# TODO: this old code requires refactoring
@register.inclusion_tag('djangobb_forum/pagination.html', takes_context=True)
def pagination(context, adjacent_pages=1):
@ -242,11 +247,6 @@ def attachment_link(attach):
return mark_safe(attachment)
@register.simple_tag
def new_reports():
return Report.objects.filter(zapped=False).count()
@register.simple_tag(takes_context=True)
def gravatar(context, email):
if forum_settings.GRAVATAR_SUPPORT:

View file

@ -66,8 +66,7 @@ def index(request, full=True):
'users_online': users_online,
'online_count': users_count,
'guest_count': guest_count,
'last_user': User.objects.latest('date_joined'),
'can_view_reports': user.has_perm('djangobb_forum.change_report')
'last_user': User.objects.latest('date_joined')
}
if full:
return render(request, 'djangobb_forum/index.html', to_return)