Commit 3bdc9e4c4b46b3f8f953b8f48ee81a72fae3a2dd

Authored by Luan
1 parent ad4d92eb

Adding description on subscriptions manage page

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,23 @@ 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=None):
48 48 url = get_url()
  49 +
  50 + kwargs = {'address': address}
  51 + if description:
  52 + kwargs.update(description=description)
  53 +
49 54 try:
50   - lists = requests.get(url, timeout=TIMEOUT, params={'address': address})
  55 + lists = requests.get(url, timeout=TIMEOUT, params=kwargs)
51 56 except requests.exceptions.RequestException:
52 57 return []
53 58  
54 59 return lists.json()
55 60  
56 61  
57   -def all_lists():
58   - return address_lists('')
  62 +def all_lists(*args, **kwargs):
  63 + return address_lists('', *args, **kwargs)
59 64  
60 65  
61 66 def user_lists(user):
... ...
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=1)
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  
... ...