From a2b437aa6f6b449c3ae438bf57132729e89f5bdf Mon Sep 17 00:00:00 2001 From: Carlos Oliveira Date: Thu, 6 Aug 2015 16:43:16 -0300 Subject: [PATCH] Updated mailing_lists to mailman-api v2 --- colab/accounts/forms.py | 5 +++-- colab/accounts/templates/accounts/user_detail.html | 1 - colab/accounts/utils/mailman.py | 6 ++++-- colab/accounts/views.py | 7 ++++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/colab/accounts/forms.py b/colab/accounts/forms.py index 74062dc..19a2272 100644 --- a/colab/accounts/forms.py +++ b/colab/accounts/forms.py @@ -141,8 +141,9 @@ class UserUpdateForm(UserForm): class ListsForm(forms.Form): LISTS_NAMES = (( - listname, u'{} ({})'.format(listname, description) - ) for listname, description in mailman.all_lists(description=True)) + mlist.get('listname'), u'{} ({})'.format(mlist.get('listname'), + mlist.get('description')) + ) for mlist in mailman.all_lists()) lists = forms.MultipleChoiceField(label=_(u'Mailing lists'), required=False, diff --git a/colab/accounts/templates/accounts/user_detail.html b/colab/accounts/templates/accounts/user_detail.html index 67c0d46..ff7acb1 100644 --- a/colab/accounts/templates/accounts/user_detail.html +++ b/colab/accounts/templates/accounts/user_detail.html @@ -84,7 +84,6 @@ {% endif %} {% endif %} - {% if user_.mailinglists %} {% trans 'Groups: ' %} {% for list in user_.mailinglists %} diff --git a/colab/accounts/utils/mailman.py b/colab/accounts/utils/mailman.py index b90bbdb..73d3896 100644 --- a/colab/accounts/utils/mailman.py +++ b/colab/accounts/utils/mailman.py @@ -73,9 +73,10 @@ def update_subscription(address, lists): def mailing_lists(**kwargs): url = get_url() + path = 'lists/' try: - lists = requests.get(url, timeout=TIMEOUT, params=kwargs) + lists = requests.get(url + path, timeout=TIMEOUT, params=kwargs) except: LOGGER.exception('Unable to list mailing lists') return [] @@ -98,7 +99,8 @@ def user_lists(user): list_set = set() for email in user.emails.values_list('address', flat=True): - list_set.update(mailing_lists(address=email)) + mlists = mailing_lists(address=email) + list_set.update(mlist.get('listname') for mlist in mlists) return tuple(list_set) diff --git a/colab/accounts/views.py b/colab/accounts/views.py index a35f4e9..de88a59 100644 --- a/colab/accounts/views.py +++ b/colab/accounts/views.py @@ -163,13 +163,14 @@ class ManageUserSubscriptionsView(UserProfileBaseMixin, DetailView): for email in emails: lists = [] lists_for_address = mailman.mailing_lists(address=email) - for listname, description in all_lists: - if listname in lists_for_address: + for mlist in all_lists: + if mlist.get('listname') in lists_for_address: checked = True else: checked = False lists.append(( - {'listname': listname, 'description': description}, + {'listname': mlist.get('listname'), + 'description': mlist.get('description')}, checked )) -- libgit2 0.21.2