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,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,22 @@ def update_subscription(address, lists): | @@ -44,18 +44,22 @@ 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=''): |
| 48 | url = get_url() | 48 | url = get_url() |
| 49 | + | ||
| 50 | + params = {'address': address, | ||
| 51 | + 'description': description} | ||
| 52 | + | ||
| 49 | try: | 53 | try: |
| 50 | - lists = requests.get(url, timeout=TIMEOUT, params={'address': address}) | 54 | + lists = requests.get(url, timeout=TIMEOUT, params=params) |
| 51 | except requests.exceptions.RequestException: | 55 | except requests.exceptions.RequestException: |
| 52 | return [] | 56 | return [] |
| 53 | 57 | ||
| 54 | return lists.json() | 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 | def user_lists(user): | 65 | def user_lists(user): |
| @@ -65,3 +69,10 @@ def user_lists(user): | @@ -65,3 +69,10 @@ def user_lists(user): | ||
| 65 | list_set.update(address_lists(email)) | 69 | list_set.update(address_lists(email)) |
| 66 | 70 | ||
| 67 | return tuple(list_set) | 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,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=True) |
| 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 |
src/super_archives/templates/superarchives/thread-dashboard.html
| @@ -5,9 +5,9 @@ | @@ -5,9 +5,9 @@ | ||
| 5 | <h2>{% trans 'Groups'|title %}</h2> | 5 | <h2>{% trans 'Groups'|title %}</h2> |
| 6 | <hr/> | 6 | <hr/> |
| 7 | 7 | ||
| 8 | - {% for listname, latest, most_relevant in lists %} | 8 | + {% for listname, description, latest, most_relevant in lists %} |
| 9 | {% if latest or most_relevant %} | 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 | <hr/> | 11 | <hr/> |
| 12 | 12 | ||
| 13 | <div class="row"> | 13 | <div class="row"> |
src/super_archives/views.py
| @@ -20,6 +20,7 @@ from django.shortcuts import render, redirect, get_object_or_404 | @@ -20,6 +20,7 @@ from django.shortcuts import render, redirect, get_object_or_404 | ||
| 20 | 20 | ||
| 21 | from haystack.query import SearchQuerySet | 21 | from haystack.query import SearchQuerySet |
| 22 | 22 | ||
| 23 | +from accounts.utils import mailman | ||
| 23 | from .utils.email import send_verification_email | 24 | from .utils.email import send_verification_email |
| 24 | from .models import MailingList, Thread, EmailAddress, \ | 25 | from .models import MailingList, Thread, EmailAddress, \ |
| 25 | EmailAddressValidation, Message | 26 | EmailAddressValidation, Message |
| @@ -120,12 +121,14 @@ class ThreadDashboardView(View): | @@ -120,12 +121,14 @@ class ThreadDashboardView(View): | ||
| 120 | def get(self, request): | 121 | def get(self, request): |
| 121 | MAX = 6 | 122 | MAX = 6 |
| 122 | context = {} | 123 | context = {} |
| 124 | + all_lists = mailman.all_lists(description=True) | ||
| 123 | 125 | ||
| 124 | context['lists'] = [] | 126 | context['lists'] = [] |
| 125 | lists = MailingList.objects.filter() | 127 | lists = MailingList.objects.filter() |
| 126 | for list_ in MailingList.objects.order_by('name'): | 128 | for list_ in MailingList.objects.order_by('name'): |
| 127 | context['lists'].append(( | 129 | context['lists'].append(( |
| 128 | list_.name, | 130 | list_.name, |
| 131 | + mailman.get_list_description(list_.name, all_lists), | ||
| 129 | list_.thread_set.filter(spam=False).order_by( | 132 | list_.thread_set.filter(spam=False).order_by( |
| 130 | '-latest_message__received_time' | 133 | '-latest_message__received_time' |
| 131 | )[:MAX], | 134 | )[:MAX], |