From 085b48ee31c8f17442d47ca7ddb8589664fceca4 Mon Sep 17 00:00:00 2001 From: Marco Rougeth Date: Tue, 19 Aug 2014 09:59:02 -0300 Subject: [PATCH] Add number of members in each group in /archives/thread/ --- src/accounts/utils/mailman.py | 13 +++++++++++++ src/super_archives/templates/superarchives/thread-dashboard.html | 6 +++++- src/super_archives/views.py | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/accounts/utils/mailman.py b/src/accounts/utils/mailman.py index 0f3c7d1..07fe7ac 100644 --- a/src/accounts/utils/mailman.py +++ b/src/accounts/utils/mailman.py @@ -82,3 +82,16 @@ def get_list_description(listname, lists=None): lists = dict(lists) return lists.get(listname) + + +def list_users(listname): + url = get_url(listname) + + params = {} + + try: + users = requests.get(url, timeout=TIMEOUT, params=params) + except requests.exceptions.RequestException: + return [] + + return users.json() diff --git a/src/super_archives/templates/superarchives/thread-dashboard.html b/src/super_archives/templates/superarchives/thread-dashboard.html index f31553e..c1452fa 100644 --- a/src/super_archives/templates/superarchives/thread-dashboard.html +++ b/src/super_archives/templates/superarchives/thread-dashboard.html @@ -7,9 +7,13 @@

{% trans 'Groups'|title %}


- {% for listname, description, latest, most_relevant in lists %} + {% for listname, description, latest, most_relevant, number_of_users in lists %} {% if latest or most_relevant %}

{{ listname|title|lower }} {% if description %} ({{ description }}){% endif %}

+
+ {{ number_of_users }} membros + Wiki +

diff --git a/src/super_archives/views.py b/src/super_archives/views.py index a056b38..4984993 100644 --- a/src/super_archives/views.py +++ b/src/super_archives/views.py @@ -133,6 +133,7 @@ class ThreadDashboardView(View): '-latest_message__received_time' )[:MAX], SearchQuerySet().filter(type='thread', tag=list_.name)[:MAX], + len(mailman.list_users(list_.name)), )) return render(request, 'superarchives/thread-dashboard.html', context) -- libgit2 0.21.2