Commit c6b6d83a3e602841195abacf66685b04782fcb44

Authored by Sergio Oliveira
1 parent e399cf33

Moving get_description to mailman utils

src/accounts/utils/mailman.py
@@ -69,3 +69,10 @@ def user_lists(user): @@ -69,3 +69,10 @@ def user_lists(user):
69 list_set.update(address_lists(email)) 69 list_set.update(address_lists(email))
70 70
71 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/super_archives/views.py
@@ -26,14 +26,6 @@ from .models import MailingList, Thread, EmailAddress, \ @@ -26,14 +26,6 @@ from .models import MailingList, Thread, EmailAddress, \
26 EmailAddressValidation, Message 26 EmailAddressValidation, Message
27 27
28 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 -  
37 class ThreadView(View): 29 class ThreadView(View):
38 http_method_names = [u'get', u'post'] 30 http_method_names = [u'get', u'post']
39 31
@@ -129,14 +121,14 @@ class ThreadDashboardView(View): @@ -129,14 +121,14 @@ class ThreadDashboardView(View):
129 def get(self, request): 121 def get(self, request):
130 MAX = 6 122 MAX = 6
131 context = {} 123 context = {}
132 - all_lists = mailman.all_lists(description=1) 124 + all_lists = mailman.all_lists(description=True)
133 125
134 context['lists'] = [] 126 context['lists'] = []
135 lists = MailingList.objects.filter() 127 lists = MailingList.objects.filter()
136 for list_ in MailingList.objects.order_by('name'): 128 for list_ in MailingList.objects.order_by('name'):
137 context['lists'].append(( 129 context['lists'].append((
138 list_.name, 130 list_.name,
139 - get_description(all_lists, list_.name), 131 + mailman.get_list_description(list_.name, all_lists),
140 list_.thread_set.filter(spam=False).order_by( 132 list_.thread_set.filter(spam=False).order_by(
141 '-latest_message__received_time' 133 '-latest_message__received_time'
142 )[:MAX], 134 )[:MAX],