__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.db import models
[docs]class ForumQuerySet(models.QuerySet):
[docs] def anchors(self):
"""Return only the Forums which do not have a parent."""
return self.filter(parent_object_id__isnull=True)
[docs]class PostQuerySet(models.QuerySet):
[docs] def anchors(self):
"""Return only the Posts which do not have a Post as a parent."""
from django.contrib.contenttypes.models import ContentType
type_forum = ContentType.objects.get_by_natural_key("forums", "forum")
type_meeting = ContentType.objects.get_by_natural_key("forums", "meeting")
return self.filter(parent_content_type__in=[type_forum, type_meeting])
[docs] def motions_excluded(self):
"""Filter all Motions out of the Post queryset."""
return self.filter(motion__isnull=True)