Commit c775a189 by benjaoming

#111 Add ancestor generator to Article

parent 9ca892d8
......@@ -89,6 +89,12 @@ class Article(models.Model):
def can_assign(self, user):
return permissions.can_assign(self, user)
def ancestor_objects(self):
"""NB! This generator is expensive, so use it with care!!"""
for obj in self.articleforobject_set.filter(is_mptt=True):
for ancestor in obj.content_object.get_ancestors():
yield ancestor
def descendant_objects(self):
"""NB! This generator is expensive, so use it with care!!"""
for obj in self.articleforobject_set.filter(is_mptt=True):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment