Commit f3b2dec146f08cf1a9624753c218de9c6da528c7

Authored by Carlos Coêlho
1 parent 8d1f236c

Updated mailing_lists to mailman-api v2

Signed-off-by: Carlos Oliveira <carlospecter@gmail.com>
colab/accounts/forms.py
@@ -141,8 +141,9 @@ class UserUpdateForm(UserForm): @@ -141,8 +141,9 @@ class UserUpdateForm(UserForm):
141 141
142 class ListsForm(forms.Form): 142 class ListsForm(forms.Form):
143 LISTS_NAMES = (( 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 lists = forms.MultipleChoiceField(label=_(u'Mailing lists'), 148 lists = forms.MultipleChoiceField(label=_(u'Mailing lists'),
148 required=False, 149 required=False,
colab/accounts/templates/accounts/user_detail.html
@@ -84,7 +84,6 @@ @@ -84,7 +84,6 @@
84 {% endif %} 84 {% endif %}
85 {% endif %} 85 {% endif %}
86 </ul> 86 </ul>
87 -  
88 {% if user_.mailinglists %} 87 {% if user_.mailinglists %}
89 <b>{% trans 'Groups: ' %}</b> 88 <b>{% trans 'Groups: ' %}</b>
90 {% for list in user_.mailinglists %} 89 {% for list in user_.mailinglists %}
colab/accounts/utils/mailman.py
@@ -73,9 +73,10 @@ def update_subscription(address, lists): @@ -73,9 +73,10 @@ def update_subscription(address, lists):
73 73
74 def mailing_lists(**kwargs): 74 def mailing_lists(**kwargs):
75 url = get_url() 75 url = get_url()
  76 + path = 'lists/'
76 77
77 try: 78 try:
78 - lists = requests.get(url, timeout=TIMEOUT, params=kwargs) 79 + lists = requests.get(url + path, timeout=TIMEOUT, params=kwargs)
79 except: 80 except:
80 LOGGER.exception('Unable to list mailing lists') 81 LOGGER.exception('Unable to list mailing lists')
81 return [] 82 return []
@@ -98,7 +99,8 @@ def user_lists(user): @@ -98,7 +99,8 @@ def user_lists(user):
98 list_set = set() 99 list_set = set()
99 100
100 for email in user.emails.values_list('address', flat=True): 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 return tuple(list_set) 105 return tuple(list_set)
104 106
colab/accounts/views.py
@@ -158,13 +158,14 @@ class ManageUserSubscriptionsView(UserProfileBaseMixin, DetailView): @@ -158,13 +158,14 @@ class ManageUserSubscriptionsView(UserProfileBaseMixin, DetailView):
158 for email in emails: 158 for email in emails:
159 lists = [] 159 lists = []
160 lists_for_address = mailman.mailing_lists(address=email) 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 checked = True 163 checked = True
164 else: 164 else:
165 checked = False 165 checked = False
166 lists.append(( 166 lists.append((
167 - {'listname': listname, 'description': description}, 167 + {'listname': mlist.get('listname'),
  168 + 'description': mlist.get('description')},
168 checked 169 checked
169 )) 170 ))
170 171