prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  comments: make sure blocked comments are not searched or filtered for their category
  **URL:** 
  **user:** 
  **expected behaviour:** when I search for sth. in the comments, I do not expect to find blocked comments, of which I cannot see the comment text
  **behaviour:** because the search happens in the backend, blocked comments are also searched, while the comment list from the serializer does not show the comment text of searched comments
  **important screensize:**
  **device & browser:** 
  **Comment/Question:** 
  
  Screenshot?
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `adhocracy4/comments_async/filters.py`
  Content:
  ```
  1 from django.db import models
  2 from rest_framework.filters import BaseFilterBackend
  3 from rest_framework.filters import SearchFilter
  4 
  5 
  6 class CommentCategoryFilterBackend(BaseFilterBackend):
  7     """Filter the comments for the categories."""
  8 
  9     def filter_queryset(self, request, queryset, view):
  10 
  11         if 'comment_category' in request.GET:
  12             category = request.GET['comment_category']
  13             return queryset.filter(comment_categories__contains=category)
  14 
  15         return queryset
  16 
  17 
  18 class CommentOrderingFilterBackend(BaseFilterBackend):
  19     """Order the comments."""
  20 
  21     def filter_queryset(self, request, queryset, view):
  22 
  23         if 'ordering' in request.GET:
  24             ordering = request.GET['ordering']
  25 
  26             if ordering == 'new':
  27                 return queryset.order_by('-created')
  28             elif ordering == 'ans':
  29                 queryset = queryset\
  30                     .annotate(comment_count=models.Count(
  31                         'child_comments', distinct=True))
  32                 return queryset.order_by('-comment_count', '-created')
  33             elif ordering == 'pos':
  34                 queryset = queryset\
  35                     .annotate(positive_rating_count=models.Count(
  36                         models.Case(
  37                             models.When(
  38                                 ratings__value=1,
  39                                 then=models.F('ratings__id')
  40                             ),
  41                             output_field=models.IntegerField()
  42                         ),
  43                         distinct=True))
  44                 return queryset.order_by('-positive_rating_count', '-created')
  45             elif ordering == 'neg':
  46                 queryset = queryset\
  47                     .annotate(negative_rating_count=models.Count(
  48                         models.Case(
  49                             models.When(
  50                                 ratings__value=-1,
  51                                 then=models.F('ratings__id')
  52                             ),
  53                             output_field=models.IntegerField()
  54                         ),
  55                         distinct=True))
  56                 return queryset.order_by('-negative_rating_count', '-created')
  57             elif ordering == 'dis':
  58                 return queryset.order_by(
  59                     models.F('last_discussed').desc(nulls_last=True),
  60                     '-created'
  61                 )
  62             elif ordering == 'mom':
  63                 return queryset.order_by('-is_moderator_marked', '-created')
  64 
  65         return queryset
  66 
  67 
  68 class CustomSearchFilter(SearchFilter):
  69 
  70     def filter_queryset(self, request, queryset, view):
  71         qs = super().filter_queryset(request, queryset, view)
  72         if self.get_search_terms(request):
  73             return qs.filter(is_removed=False, is_censored=False)
  74         return qs
  75
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/adhocracy4/comments_async/filters.py b/adhocracy4/comments_async/filters.py
  --- a/adhocracy4/comments_async/filters.py
  +++ b/adhocracy4/comments_async/filters.py
  @@ -8,9 +8,12 @@
   
       def filter_queryset(self, request, queryset, view):
   
  -        if 'comment_category' in request.GET:
  +        if ('comment_category' in request.GET
  +                and request.GET['comment_category'] != ''):
               category = request.GET['comment_category']
  -            return queryset.filter(comment_categories__contains=category)
  +            return queryset.filter(
  +                comment_categories__contains=category,
  +                is_blocked=False)
   
           return queryset
   
  @@ -70,5 +73,6 @@
       def filter_queryset(self, request, queryset, view):
           qs = super().filter_queryset(request, queryset, view)
           if self.get_search_terms(request):
  -            return qs.filter(is_removed=False, is_censored=False)
  +            return qs.filter(is_removed=False, is_censored=False,
  +                             is_blocked=False)
           return qs
  
verification_info: {"golden_diff": "diff --git a/adhocracy4/comments_async/filters.py b/adhocracy4/comments_async/filters.py\n--- a/adhocracy4/comments_async/filters.py\n+++ b/adhocracy4/comments_async/filters.py\n@@ -8,9 +8,12 @@\n \n     def filter_queryset(self, request, queryset, view):\n \n-        if 'comment_category' in request.GET:\n+        if ('comment_category' in request.GET\n+                and request.GET['comment_category'] != ''):\n             category = request.GET['comment_category']\n-            return queryset.filter(comment_categories__contains=category)\n+            return queryset.filter(\n+                comment_categories__contains=category,\n+                is_blocked=False)\n \n         return queryset\n \n@@ -70,5 +73,6 @@\n     def filter_queryset(self, request, queryset, view):\n         qs = super().filter_queryset(request, queryset, view)\n         if self.get_search_terms(request):\n-            return qs.filter(is_removed=False, is_censored=False)\n+            return qs.filter(is_removed=False, is_censored=False,\n+                             is_blocked=False)\n         return qs\n", "issue": "comments: make sure blocked comments are not searched or filtered for their category\n**URL:** \r\n**user:** \r\n**expected behaviour:** when I search for sth. in the comments, I do not expect to find blocked comments, of which I cannot see the comment text\r\n**behaviour:** because the search happens in the backend, blocked comments are also searched, while the comment list from the serializer does not show the comment text of searched comments\r\n**important screensize:**\r\n**device & browser:** \r\n**Comment/Question:** \r\n\r\nScreenshot?\r\n\n", "before_files": [{"content": "from django.db import models\nfrom rest_framework.filters import BaseFilterBackend\nfrom rest_framework.filters import SearchFilter\n\n\nclass CommentCategoryFilterBackend(BaseFilterBackend):\n    \"\"\"Filter the comments for the categories.\"\"\"\n\n    def filter_queryset(self, request, queryset, view):\n\n        if 'comment_category' in request.GET:\n            category = request.GET['comment_category']\n            return queryset.filter(comment_categories__contains=category)\n\n        return queryset\n\n\nclass CommentOrderingFilterBackend(BaseFilterBackend):\n    \"\"\"Order the comments.\"\"\"\n\n    def filter_queryset(self, request, queryset, view):\n\n        if 'ordering' in request.GET:\n            ordering = request.GET['ordering']\n\n            if ordering == 'new':\n                return queryset.order_by('-created')\n            elif ordering == 'ans':\n                queryset = queryset\\\n                    .annotate(comment_count=models.Count(\n                        'child_comments', distinct=True))\n                return queryset.order_by('-comment_count', '-created')\n            elif ordering == 'pos':\n                queryset = queryset\\\n                    .annotate(positive_rating_count=models.Count(\n                        models.Case(\n                            models.When(\n                                ratings__value=1,\n                                then=models.F('ratings__id')\n                            ),\n                            output_field=models.IntegerField()\n                        ),\n                        distinct=True))\n                return queryset.order_by('-positive_rating_count', '-created')\n            elif ordering == 'neg':\n                queryset = queryset\\\n                    .annotate(negative_rating_count=models.Count(\n                        models.Case(\n                            models.When(\n                                ratings__value=-1,\n                                then=models.F('ratings__id')\n                            ),\n                            output_field=models.IntegerField()\n                        ),\n                        distinct=True))\n                return queryset.order_by('-negative_rating_count', '-created')\n            elif ordering == 'dis':\n                return queryset.order_by(\n                    models.F('last_discussed').desc(nulls_last=True),\n                    '-created'\n                )\n            elif ordering == 'mom':\n                return queryset.order_by('-is_moderator_marked', '-created')\n\n        return queryset\n\n\nclass CustomSearchFilter(SearchFilter):\n\n    def filter_queryset(self, request, queryset, view):\n        qs = super().filter_queryset(request, queryset, view)\n        if self.get_search_terms(request):\n            return qs.filter(is_removed=False, is_censored=False)\n        return qs\n", "path": "adhocracy4/comments_async/filters.py"}], "after_files": [{"content": "from django.db import models\nfrom rest_framework.filters import BaseFilterBackend\nfrom rest_framework.filters import SearchFilter\n\n\nclass CommentCategoryFilterBackend(BaseFilterBackend):\n    \"\"\"Filter the comments for the categories.\"\"\"\n\n    def filter_queryset(self, request, queryset, view):\n\n        if ('comment_category' in request.GET\n                and request.GET['comment_category'] != ''):\n            category = request.GET['comment_category']\n            return queryset.filter(\n                comment_categories__contains=category,\n                is_blocked=False)\n\n        return queryset\n\n\nclass CommentOrderingFilterBackend(BaseFilterBackend):\n    \"\"\"Order the comments.\"\"\"\n\n    def filter_queryset(self, request, queryset, view):\n\n        if 'ordering' in request.GET:\n            ordering = request.GET['ordering']\n\n            if ordering == 'new':\n                return queryset.order_by('-created')\n            elif ordering == 'ans':\n                queryset = queryset\\\n                    .annotate(comment_count=models.Count(\n                        'child_comments', distinct=True))\n                return queryset.order_by('-comment_count', '-created')\n            elif ordering == 'pos':\n                queryset = queryset\\\n                    .annotate(positive_rating_count=models.Count(\n                        models.Case(\n                            models.When(\n                                ratings__value=1,\n                                then=models.F('ratings__id')\n                            ),\n                            output_field=models.IntegerField()\n                        ),\n                        distinct=True))\n                return queryset.order_by('-positive_rating_count', '-created')\n            elif ordering == 'neg':\n                queryset = queryset\\\n                    .annotate(negative_rating_count=models.Count(\n                        models.Case(\n                            models.When(\n                                ratings__value=-1,\n                                then=models.F('ratings__id')\n                            ),\n                            output_field=models.IntegerField()\n                        ),\n                        distinct=True))\n                return queryset.order_by('-negative_rating_count', '-created')\n            elif ordering == 'dis':\n                return queryset.order_by(\n                    models.F('last_discussed').desc(nulls_last=True),\n                    '-created'\n                )\n            elif ordering == 'mom':\n                return queryset.order_by('-is_moderator_marked', '-created')\n\n        return queryset\n\n\nclass CustomSearchFilter(SearchFilter):\n\n    def filter_queryset(self, request, queryset, view):\n        qs = super().filter_queryset(request, queryset, view)\n        if self.get_search_terms(request):\n            return qs.filter(is_removed=False, is_censored=False,\n                             is_blocked=False)\n        return qs\n", "path": "adhocracy4/comments_async/filters.py"}]}