Commit 085b48ee31c8f17442d47ca7ddb8589664fceca4
Committed by
Sergio Oliveira
1 parent
503c7446
Exists in
master
and in
39 other branches
Add number of members in each group in /archives/thread/
Showing
3 changed files
with
19 additions
and
1 deletions
Show diff stats
src/accounts/utils/mailman.py
... | ... | @@ -82,3 +82,16 @@ def get_list_description(listname, lists=None): |
82 | 82 | lists = dict(lists) |
83 | 83 | |
84 | 84 | return lists.get(listname) |
85 | + | |
86 | + | |
87 | +def list_users(listname): | |
88 | + url = get_url(listname) | |
89 | + | |
90 | + params = {} | |
91 | + | |
92 | + try: | |
93 | + users = requests.get(url, timeout=TIMEOUT, params=params) | |
94 | + except requests.exceptions.RequestException: | |
95 | + return [] | |
96 | + | |
97 | + return users.json() | ... | ... |
src/super_archives/templates/superarchives/thread-dashboard.html
... | ... | @@ -7,9 +7,13 @@ |
7 | 7 | <h2>{% trans 'Groups'|title %}</h2> |
8 | 8 | <hr/> |
9 | 9 | |
10 | - {% for listname, description, latest, most_relevant in lists %} | |
10 | + {% for listname, description, latest, most_relevant, number_of_users in lists %} | |
11 | 11 | {% if latest or most_relevant %} |
12 | 12 | <h3><b>{{ listname|title|lower }} {% if description %} ({{ description }}){% endif %}</b></h3> |
13 | + <div class="btn-group btn-group-sm"> | |
14 | + <a href="#" class="btn btn-default" disabled="disabled">{{ number_of_users }} membros</a> | |
15 | + <a href="/wiki/grupos/{{listname}}" class="btn btn-default">Wiki</a> | |
16 | + </div> | |
13 | 17 | <hr/> |
14 | 18 | |
15 | 19 | <div class="row"> | ... | ... |
src/super_archives/views.py
... | ... | @@ -133,6 +133,7 @@ class ThreadDashboardView(View): |
133 | 133 | '-latest_message__received_time' |
134 | 134 | )[:MAX], |
135 | 135 | SearchQuerySet().filter(type='thread', tag=list_.name)[:MAX], |
136 | + len(mailman.list_users(list_.name)), | |
136 | 137 | )) |
137 | 138 | |
138 | 139 | return render(request, 'superarchives/thread-dashboard.html', context) | ... | ... |