views,models: simplify code computing transitive closure of MailingList models
This commit is contained in:
parent
a87ab42812
commit
a2e2887bf2
|
@ -575,12 +575,11 @@ class MailingListManager(GetByNameManager):
|
|||
|
||||
def are_member_of(self, users):
|
||||
lists = set(MailingList.objects.filter(members__in=users))
|
||||
count = len(lists)
|
||||
while True: # accumulate lists until it grows no more
|
||||
old_count = len(lists)
|
||||
lists |= set(MailingList.objects.filter(mailing_list_members__in=lists))
|
||||
if count == len(lists):
|
||||
if old_count == len(lists):
|
||||
break
|
||||
count = len(lists)
|
||||
return lists
|
||||
|
||||
|
||||
|
|
|
@ -69,12 +69,11 @@ def user_mailing_list_names(user):
|
|||
|
||||
def recursive_lists(lists):
|
||||
lists = set(lists)
|
||||
count = len(lists)
|
||||
while True:
|
||||
old_count = len(lists)
|
||||
lists |= set(MailingList.objects.filter(members_lists__in=lists))
|
||||
if len(lists) == count:
|
||||
if len(lists) == old_count:
|
||||
break
|
||||
count = len(lists)
|
||||
return lists
|
||||
|
||||
def get_file_form_kwargs(request):
|
||||
|
|
Loading…
Reference in New Issue