Commit c6b6d83a3e602841195abacf66685b04782fcb44
1 parent
e399cf33
Exists in
master
and in
39 other branches
Moving get_description to mailman utils
Showing
2 changed files
with
9 additions
and
10 deletions
Show diff stats
src/accounts/utils/mailman.py
| ... | ... | @@ -69,3 +69,10 @@ def user_lists(user): |
| 69 | 69 | list_set.update(address_lists(email)) |
| 70 | 70 | |
| 71 | 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 | 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 | 29 | class ThreadView(View): |
| 38 | 30 | http_method_names = [u'get', u'post'] |
| 39 | 31 | |
| ... | ... | @@ -129,14 +121,14 @@ class ThreadDashboardView(View): |
| 129 | 121 | def get(self, request): |
| 130 | 122 | MAX = 6 |
| 131 | 123 | context = {} |
| 132 | - all_lists = mailman.all_lists(description=1) | |
| 124 | + all_lists = mailman.all_lists(description=True) | |
| 133 | 125 | |
| 134 | 126 | context['lists'] = [] |
| 135 | 127 | lists = MailingList.objects.filter() |
| 136 | 128 | for list_ in MailingList.objects.order_by('name'): |
| 137 | 129 | context['lists'].append(( |
| 138 | 130 | list_.name, |
| 139 | - get_description(all_lists, list_.name), | |
| 131 | + mailman.get_list_description(list_.name, all_lists), | |
| 140 | 132 | list_.thread_set.filter(spam=False).order_by( |
| 141 | 133 | '-latest_message__received_time' |
| 142 | 134 | )[:MAX], | ... | ... |