Commit f3b2dec146f08cf1a9624753c218de9c6da528c7
1 parent
8d1f236c
Updated mailing_lists to mailman-api v2
Signed-off-by: Carlos Oliveira <carlospecter@gmail.com>
Showing
4 changed files
with
11 additions
and
8 deletions
Show diff stats
colab/accounts/forms.py
| ... | ... | @@ -141,8 +141,9 @@ class UserUpdateForm(UserForm): |
| 141 | 141 | |
| 142 | 142 | class ListsForm(forms.Form): |
| 143 | 143 | LISTS_NAMES = (( |
| 144 | - listname, u'{} ({})'.format(listname, description) | |
| 145 | - ) for listname, description in mailman.all_lists(description=True)) | |
| 144 | + mlist.get('listname'), u'{} ({})'.format(mlist.get('listname'), | |
| 145 | + mlist.get('description')) | |
| 146 | + ) for mlist in mailman.all_lists()) | |
| 146 | 147 | |
| 147 | 148 | lists = forms.MultipleChoiceField(label=_(u'Mailing lists'), |
| 148 | 149 | required=False, | ... | ... |
colab/accounts/templates/accounts/user_detail.html
colab/accounts/utils/mailman.py
| ... | ... | @@ -73,9 +73,10 @@ def update_subscription(address, lists): |
| 73 | 73 | |
| 74 | 74 | def mailing_lists(**kwargs): |
| 75 | 75 | url = get_url() |
| 76 | + path = 'lists/' | |
| 76 | 77 | |
| 77 | 78 | try: |
| 78 | - lists = requests.get(url, timeout=TIMEOUT, params=kwargs) | |
| 79 | + lists = requests.get(url + path, timeout=TIMEOUT, params=kwargs) | |
| 79 | 80 | except: |
| 80 | 81 | LOGGER.exception('Unable to list mailing lists') |
| 81 | 82 | return [] |
| ... | ... | @@ -98,7 +99,8 @@ def user_lists(user): |
| 98 | 99 | list_set = set() |
| 99 | 100 | |
| 100 | 101 | for email in user.emails.values_list('address', flat=True): |
| 101 | - list_set.update(mailing_lists(address=email)) | |
| 102 | + mlists = mailing_lists(address=email) | |
| 103 | + list_set.update(mlist.get('listname') for mlist in mlists) | |
| 102 | 104 | |
| 103 | 105 | return tuple(list_set) |
| 104 | 106 | ... | ... |
colab/accounts/views.py
| ... | ... | @@ -158,13 +158,14 @@ class ManageUserSubscriptionsView(UserProfileBaseMixin, DetailView): |
| 158 | 158 | for email in emails: |
| 159 | 159 | lists = [] |
| 160 | 160 | lists_for_address = mailman.mailing_lists(address=email) |
| 161 | - for listname, description in all_lists: | |
| 162 | - if listname in lists_for_address: | |
| 161 | + for mlist in all_lists: | |
| 162 | + if mlist.get('listname') in lists_for_address: | |
| 163 | 163 | checked = True |
| 164 | 164 | else: |
| 165 | 165 | checked = False |
| 166 | 166 | lists.append(( |
| 167 | - {'listname': listname, 'description': description}, | |
| 167 | + {'listname': mlist.get('listname'), | |
| 168 | + 'description': mlist.get('description')}, | |
| 168 | 169 | checked |
| 169 | 170 | )) |
| 170 | 171 | ... | ... |