Use already_notified in get_all_groups
This commit is contained in:
parent
f257209f8f
commit
9c02e1e902
1 changed files with 8 additions and 2 deletions
|
@ -70,14 +70,20 @@ class WikiGroup(models.Model):
|
|||
|
||||
return False
|
||||
|
||||
def get_all_groups(self):
|
||||
def get_all_groups(self, already_notified=None):
|
||||
"""Returns the set of metagroups i.e. self plus the list of groups including
|
||||
this group recursively"""
|
||||
|
||||
if already_notified is None:
|
||||
already_notified = set()
|
||||
elif self.pk in already_notified:
|
||||
return set()
|
||||
already_notified.add(self.pk)
|
||||
|
||||
groups = {self}
|
||||
|
||||
for metagroup in self.included_in_groups.all():
|
||||
groups |= metagroup.get_all_groups()
|
||||
groups |= metagroup.get_all_groups(already_notified=already_notified)
|
||||
|
||||
return groups
|
||||
|
||||
|
|
Loading…
Reference in a new issue