Commit a40b7a43edcfce42b4bf6e468f0c1710cac9f9f6
Exists in
master
and in
39 other branches
Merge pull request #144 from TracyWebTech/adding_groups_description
Adding groups description
Showing
5 changed files
with
27 additions
and
10 deletions
Show diff stats
src/accounts/templates/accounts/manage_subscriptions.html
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | {% for list, checked in lists %} |
22 | 22 | <div class="checkbox"> |
23 | 23 | <label> |
24 | - <input name="{{ email }}" value="{{ list }}" type="checkbox" {% if checked %}checked{% endif%}>{{ list }}</input> | |
24 | + <input name="{{ email }}" value="{{ list.listname }}" type="checkbox" {% if checked %}checked{% endif%} title="{{ list.description }}">{{ list.listname }}</input> | |
25 | 25 | </label> |
26 | 26 | </div> |
27 | 27 | {% endfor %} | ... | ... |
src/accounts/utils/mailman.py
... | ... | @@ -44,18 +44,22 @@ def update_subscription(address, lists): |
44 | 44 | subscribe(maillist, address) |
45 | 45 | |
46 | 46 | |
47 | -def address_lists(address): | |
47 | +def address_lists(address, description=''): | |
48 | 48 | url = get_url() |
49 | + | |
50 | + params = {'address': address, | |
51 | + 'description': description} | |
52 | + | |
49 | 53 | try: |
50 | - lists = requests.get(url, timeout=TIMEOUT, params={'address': address}) | |
54 | + lists = requests.get(url, timeout=TIMEOUT, params=params) | |
51 | 55 | except requests.exceptions.RequestException: |
52 | 56 | return [] |
53 | 57 | |
54 | 58 | return lists.json() |
55 | 59 | |
56 | 60 | |
57 | -def all_lists(): | |
58 | - return address_lists('') | |
61 | +def all_lists(*args, **kwargs): | |
62 | + return address_lists('', *args, **kwargs) | |
59 | 63 | |
60 | 64 | |
61 | 65 | def user_lists(user): |
... | ... | @@ -65,3 +69,10 @@ def user_lists(user): |
65 | 69 | list_set.update(address_lists(email)) |
66 | 70 | |
67 | 71 | return tuple(list_set) |
72 | + | |
73 | + | |
74 | +def get_list_description(listname, lists=None): | |
75 | + if not lists: | |
76 | + lists = dict(all_lists(description=True)) | |
77 | + | |
78 | + return lists.get(listname) | ... | ... |
src/accounts/views.py
... | ... | @@ -174,17 +174,20 @@ class ManageUserSubscriptionsView(UserProfileBaseMixin, DetailView): |
174 | 174 | |
175 | 175 | user = self.get_object() |
176 | 176 | emails = user.emails.values_list('address', flat=True) |
177 | - all_lists = mailman.all_lists() | |
177 | + all_lists = mailman.all_lists(description=True) | |
178 | 178 | |
179 | 179 | for email in emails: |
180 | 180 | lists = [] |
181 | 181 | lists_for_address = mailman.address_lists(email) |
182 | - for listname in all_lists: | |
182 | + for listname, description in all_lists: | |
183 | 183 | if listname in lists_for_address: |
184 | 184 | checked = True |
185 | 185 | else: |
186 | 186 | checked = False |
187 | - lists.append((listname, checked)) | |
187 | + lists.append(( | |
188 | + {'listname': listname, 'description': description}, | |
189 | + checked | |
190 | + )) | |
188 | 191 | |
189 | 192 | context['membership'].update({email: lists}) |
190 | 193 | ... | ... |
src/super_archives/templates/superarchives/thread-dashboard.html
... | ... | @@ -5,9 +5,9 @@ |
5 | 5 | <h2>{% trans 'Groups'|title %}</h2> |
6 | 6 | <hr/> |
7 | 7 | |
8 | - {% for listname, latest, most_relevant in lists %} | |
8 | + {% for listname, description, latest, most_relevant in lists %} | |
9 | 9 | {% if latest or most_relevant %} |
10 | - <h3 class="text-center"><b>{{ listname|title }}</b></h3> | |
10 | + <h3 class="text-center"><b>{{ listname|title }} {% if description %} ({{ description }}){% endif %}</b></h3> | |
11 | 11 | <hr/> |
12 | 12 | |
13 | 13 | <div class="row"> | ... | ... |
src/super_archives/views.py
... | ... | @@ -20,6 +20,7 @@ from django.shortcuts import render, redirect, get_object_or_404 |
20 | 20 | |
21 | 21 | from haystack.query import SearchQuerySet |
22 | 22 | |
23 | +from accounts.utils import mailman | |
23 | 24 | from .utils.email import send_verification_email |
24 | 25 | from .models import MailingList, Thread, EmailAddress, \ |
25 | 26 | EmailAddressValidation, Message |
... | ... | @@ -120,12 +121,14 @@ class ThreadDashboardView(View): |
120 | 121 | def get(self, request): |
121 | 122 | MAX = 6 |
122 | 123 | context = {} |
124 | + all_lists = mailman.all_lists(description=True) | |
123 | 125 | |
124 | 126 | context['lists'] = [] |
125 | 127 | lists = MailingList.objects.filter() |
126 | 128 | for list_ in MailingList.objects.order_by('name'): |
127 | 129 | context['lists'].append(( |
128 | 130 | list_.name, |
131 | + mailman.get_list_description(list_.name, all_lists), | |
129 | 132 | list_.thread_set.filter(spam=False).order_by( |
130 | 133 | '-latest_message__received_time' |
131 | 134 | )[:MAX], | ... | ... |