Bases: HistoryQuerySet
, OrderingQuerySetMixin
annotate_entry_count
Source code in django_spire/knowledge/collection/querysets.py
| def annotate_entry_count(self) -> QuerySet[Collection]:
return self.annotate(entry_count=Count('entry'))
|
by_parent
Source code in django_spire/knowledge/collection/querysets.py
| def by_parent(self, parent: Collection) -> QuerySet[Collection]:
return self.filter(parent=parent)
|
by_parent_id
Source code in django_spire/knowledge/collection/querysets.py
| def by_parent_id(self, parent_id: int) -> QuerySet[Collection]:
return self.filter(parent_id=parent_id)
|
childless
Source code in django_spire/knowledge/collection/querysets.py
| def childless(self) -> QuerySet[Collection]:
return self.annotate(child_count=Count('child')).filter(child_count=0)
|
parentless
Source code in django_spire/knowledge/collection/querysets.py
| def parentless(self) -> QuerySet[Collection]:
return self.filter(parent_id__isnull=True)
|
user_has_access
Source code in django_spire/knowledge/collection/querysets.py
| def user_has_access(self, user: AuthUser) -> QuerySet[Collection]:
direct_access = self.filter(group__auth_group__user=user)
accessible_ids = set(direct_access.values_list('id', flat=True))
current_level_ids = accessible_ids.copy()
while current_level_ids:
next_level = self.filter(parent_id__in=current_level_ids)
new_ids = set(next_level.values_list('id', flat=True)) - accessible_ids
if not new_ids:
break
accessible_ids.update(new_ids)
current_level_ids = new_ids
return self.filter(id__in=accessible_ids).distinct()
|