Commit 3bdc9e4c4b46b3f8f953b8f48ee81a72fae3a2dd
1 parent
ad4d92eb
Exists in
master
and in
39 other branches
Adding description on subscriptions manage page
Showing
3 changed files
with
16 additions
and
8 deletions
Show diff stats
src/accounts/templates/accounts/manage_subscriptions.html
| @@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
| 21 | {% for list, checked in lists %} | 21 | {% for list, checked in lists %} |
| 22 | <div class="checkbox"> | 22 | <div class="checkbox"> |
| 23 | <label> | 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 | </label> | 25 | </label> |
| 26 | </div> | 26 | </div> |
| 27 | {% endfor %} | 27 | {% endfor %} |
src/accounts/utils/mailman.py
| @@ -44,18 +44,23 @@ def update_subscription(address, lists): | @@ -44,18 +44,23 @@ def update_subscription(address, lists): | ||
| 44 | subscribe(maillist, address) | 44 | subscribe(maillist, address) |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | -def address_lists(address): | 47 | +def address_lists(address, description=None): |
| 48 | url = get_url() | 48 | url = get_url() |
| 49 | + | ||
| 50 | + kwargs = {'address': address} | ||
| 51 | + if description: | ||
| 52 | + kwargs.update(description=description) | ||
| 53 | + | ||
| 49 | try: | 54 | try: |
| 50 | - lists = requests.get(url, timeout=TIMEOUT, params={'address': address}) | 55 | + lists = requests.get(url, timeout=TIMEOUT, params=kwargs) |
| 51 | except requests.exceptions.RequestException: | 56 | except requests.exceptions.RequestException: |
| 52 | return [] | 57 | return [] |
| 53 | 58 | ||
| 54 | return lists.json() | 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 | def user_lists(user): | 66 | def user_lists(user): |
src/accounts/views.py
| @@ -174,17 +174,20 @@ class ManageUserSubscriptionsView(UserProfileBaseMixin, DetailView): | @@ -174,17 +174,20 @@ class ManageUserSubscriptionsView(UserProfileBaseMixin, DetailView): | ||
| 174 | 174 | ||
| 175 | user = self.get_object() | 175 | user = self.get_object() |
| 176 | emails = user.emails.values_list('address', flat=True) | 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 | for email in emails: | 179 | for email in emails: |
| 180 | lists = [] | 180 | lists = [] |
| 181 | lists_for_address = mailman.address_lists(email) | 181 | lists_for_address = mailman.address_lists(email) |
| 182 | - for listname in all_lists: | 182 | + for listname, description in all_lists: |
| 183 | if listname in lists_for_address: | 183 | if listname in lists_for_address: |
| 184 | checked = True | 184 | checked = True |
| 185 | else: | 185 | else: |
| 186 | checked = False | 186 | checked = False |
| 187 | - lists.append((listname, checked)) | 187 | + lists.append(( |
| 188 | + {'listname': listname: 'description': description}, | ||
| 189 | + checked | ||
| 190 | + )) | ||
| 188 | 191 | ||
| 189 | context['membership'].update({email: lists}) | 192 | context['membership'].update({email: lists}) |
| 190 | 193 |