+ if self.is_themed:
+ related_tags = []
+ current_books = self.get_queryset().values_list('book', flat=True).distinct()
+ containing_books = Book.objects.filter(Q(id__in=current_books) | Q(children__in=current_books))
+
+ related_tags.extend(list(
+ Tag.objects.usage_for_queryset(
+ containing_books,
+ ).exclude(category='set').exclude(pk__in=tag_ids)
+ ))
+ if self.request.user.is_authenticated:
+ related_tags.extend(list(
+ Tag.objects.usage_for_queryset(
+ containing_books
+ ).filter(
+ user=self.request.user
+ ).exclude(name='').exclude(pk__in=tag_ids)
+ ))
+ else:
+ related_tags = list(get_top_level_related_tags(self.ctx['tags']))