Commit 43e57b43df2eaaf696c0fee04a1e0912d16db641
1 parent
a217e1f4
Exists in
master
and in
39 other branches
Adding description to thread dashboard - closes #97
Showing
2 changed files
with
13 additions
and
2 deletions
Show diff stats
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,11 +20,20 @@ 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 |
| 26 | 27 | |
| 27 | 28 | |
| 29 | +def get_description(all_lists, listname_): | |
| 30 | + # if not isinstance(all_lists[0], (tuple, list, dict)): | |
| 31 | + # return | |
| 32 | + for listname, description in all_lists: | |
| 33 | + if listname == listname_: | |
| 34 | + return description | |
| 35 | + | |
| 36 | + | |
| 28 | 37 | class ThreadView(View): |
| 29 | 38 | http_method_names = [u'get', u'post'] |
| 30 | 39 | |
| ... | ... | @@ -120,12 +129,14 @@ class ThreadDashboardView(View): |
| 120 | 129 | def get(self, request): |
| 121 | 130 | MAX = 6 |
| 122 | 131 | context = {} |
| 132 | + all_lists = mailman.all_lists(description=1) | |
| 123 | 133 | |
| 124 | 134 | context['lists'] = [] |
| 125 | 135 | lists = MailingList.objects.filter() |
| 126 | 136 | for list_ in MailingList.objects.order_by('name'): |
| 127 | 137 | context['lists'].append(( |
| 128 | 138 | list_.name, |
| 139 | + get_description(all_lists, list_.name), | |
| 129 | 140 | list_.thread_set.filter(spam=False).order_by( |
| 130 | 141 | '-latest_message__received_time' |
| 131 | 142 | )[:MAX], | ... | ... |