From 0ac80ab1ee2860983226ebb0fe10ff672caf64cd Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Wed, 31 Jan 2018 18:02:13 +0000 Subject: [PATCH] Fixed 2 bugs in import_mailman_listinfo; one typo and one bug which prevented updating of lists that changed from advertised to not advertised. - Legacy-Id: 14600 --- .../commands/import_mailman_listinfo.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ietf/mailinglists/management/commands/import_mailman_listinfo.py b/ietf/mailinglists/management/commands/import_mailman_listinfo.py index 25b02faec..458b50ab8 100644 --- a/ietf/mailinglists/management/commands/import_mailman_listinfo.py +++ b/ietf/mailinglists/management/commands/import_mailman_listinfo.py @@ -37,14 +37,19 @@ def import_mailman_listinfo(verbosity=0): for name in names: mlist = MailList.MailList(name, lock=False) note("List: %s" % mlist.internal_name()) - sys.exit() + + description = mlist.description.decode('latin1')[:256] + lists = List.objects.filter(name=mlist.real_name) + if lists.count() > 1: + # Arbitrary choice; we'll update the remaining item next + for item in lists[1:]: + item.delete() + mmlist, created = List.objects.get_or_create(name=mlist.real_name) + mmlist.description = description + mmlist.advertised = mlist.advertised + mmlist.save() + # The following calls return lowercased addresses if mlist.advertised: - description = mlist.description.decode('latin1')[:256] - mmlist, created = List.objects.get_or_create(name=mlist.real_name) - mmlist.description = description - mmlist.advertised = mlist.advertised - mmlist.save() - # The following calls return lowercased addresses members = mlist.getRegularMemberKeys() + mlist.getDigestMemberKeys() members = [ m for m in members if mlist.getDeliveryStatus(m) == MemberAdaptor.ENABLED ] known = Subscribed.objects.filter(lists__name=name).values_list('email', flat=True)