Skip to content

Commit

Permalink
Forum index updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ellmetha committed Mar 7, 2015
1 parent f57aeb6 commit 285acfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions machina/apps/forum/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ def get_queryset(self):
self.request.user
)

def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)

top_level_forums = context['forums'].filter(parent__isnull=True)
context['total_posts_count'] = sum(f.posts_count for f in top_level_forums)
context['total_topics_count'] = sum(f.topics_count for f in top_level_forums)

return context


class ForumView(PermissionRequiredMixin, ListView):
template_name = 'forum/forum_detail.html'
Expand Down
2 changes: 2 additions & 0 deletions machina/templates/machina/forum/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
</div>
</div>
{% forum_list forums request %}
<h4 class="page-header">{% trans "Statistics" %}</h4>
<p class="statistics">{% trans "Total posts:" %}&nbsp;<b>{{ total_posts_count }}</b>&nbsp;&#8226;&nbsp;{% trans "Total topics:" %}&nbsp;<b>{{ total_topics_count }}</b>&nbsp;</p>
{% endblock content %}

0 comments on commit 285acfe

Please sign in to comment.