Commit c2179e5c46677ed5d2952a564ef13edb756c3773

Authored by Carlos Coêlho
1 parent 731470ba

Updated to Mailman API v2 usage

Signed-off-by: Carlos Oliveira <carlospecter@gmail.com>
colab/accounts/utils/mailman.py
... ... @@ -91,7 +91,10 @@ def mailing_lists(**kwargs):
91 91  
92 92 def is_private_list(name):
93 93 try:
94   - return dict(all_lists(private=True))[name]
  94 + privacy = {}
  95 + privacy.update({mlist.get('listname'): mlist.get('archive_private')
  96 + for mlist in all_lists()})
  97 + return privacy[name]
95 98 except KeyError:
96 99 return []
97 100  
... ...
colab/super_archives/views.py
... ... @@ -32,15 +32,23 @@ class ThreadView(View):
32 32 thread = get_object_or_404(Thread, subject_token=thread_token,
33 33 mailinglist__name=mailinglist)
34 34  
35   - all_privates = dict(mailman.all_lists(private=True))
36   - if all_privates[thread.mailinglist.name]:
  35 + all_privates = []
  36 + all_privates.extend(
  37 + [mlist.get('listname')
  38 + for mlist in mailman.all_lists()
  39 + if mlist.get('archive_private')]
  40 + )
  41 +
  42 + if all_privates.count(thread.mailinglist.name):
37 43 if not request.user.is_authenticated():
38 44 raise PermissionDenied
39 45 else:
40 46 user = User.objects.get(username=request.user)
41 47 emails = user.emails.values_list('address', flat=True)
42 48 lists_for_user = mailman.get_user_mailinglists(user)
43   - if thread.mailinglist.name not in lists_for_user:
  49 + listnames_for_user = [mlist.get("listname")
  50 + for mlist in lists_for_user]
  51 + if thread.mailinglist.name not in listnames_for_user:
44 52 raise PermissionDenied
45 53  
46 54 thread.hit(request)
... ...