Commit 43e57b43df2eaaf696c0fee04a1e0912d16db641

Authored by Luan
1 parent a217e1f4

Adding description to thread dashboard - closes #97

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,11 +20,20 @@ from django.shortcuts import render, redirect, get_object_or_404 @@ -20,11 +20,20 @@ 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
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 class ThreadView(View): 37 class ThreadView(View):
29 http_method_names = [u'get', u'post'] 38 http_method_names = [u'get', u'post']
30 39
@@ -120,12 +129,14 @@ class ThreadDashboardView(View): @@ -120,12 +129,14 @@ class ThreadDashboardView(View):
120 def get(self, request): 129 def get(self, request):
121 MAX = 6 130 MAX = 6
122 context = {} 131 context = {}
  132 + all_lists = mailman.all_lists(description=1)
123 133
124 context['lists'] = [] 134 context['lists'] = []
125 lists = MailingList.objects.filter() 135 lists = MailingList.objects.filter()
126 for list_ in MailingList.objects.order_by('name'): 136 for list_ in MailingList.objects.order_by('name'):
127 context['lists'].append(( 137 context['lists'].append((
128 list_.name, 138 list_.name,
  139 + get_description(all_lists, list_.name),
129 list_.thread_set.filter(spam=False).order_by( 140 list_.thread_set.filter(spam=False).order_by(
130 '-latest_message__received_time' 141 '-latest_message__received_time'
131 )[:MAX], 142 )[:MAX],