prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Filter by release channel on ASRSnippets raises an error
  
  
  </issue>
  <code>
  [start of snippets/base/admin/filters.py]
  1 from datetime import datetime, timedelta
  2 
  3 from django.contrib import admin
  4 from django.utils.encoding import force_text
  5 
  6 
  7 class ModifiedFilter(admin.SimpleListFilter):
  8     title = 'Last modified'
  9     parameter_name = 'last_modified'
  10 
  11     def lookups(self, request, model_admin):
  12         return (
  13             ('24', '24 hours'),
  14             ('168', '7 days'),
  15             ('336', '14 days'),
  16             ('720', '30 days'),
  17             ('all', 'All'),
  18         )
  19 
  20     def queryset(self, request, queryset):
  21         value = self.value()
  22         if not value or value == 'all':
  23             return queryset
  24 
  25         when = datetime.utcnow() - timedelta(hours=int(value))
  26         return queryset.exclude(modified__lt=when)
  27 
  28     def choices(self, cl):
  29         for lookup, title in self.lookup_choices:
  30             yield {
  31                 'selected': self.value() == force_text(lookup),
  32                 'query_string': cl.get_query_string({
  33                     self.parameter_name: lookup,
  34                 }, []),
  35                 'display': title,
  36             }
  37 
  38 
  39 class ChannelFilter(admin.SimpleListFilter):
  40     title = 'Channel'
  41     parameter_name = 'channel'
  42 
  43     def lookups(self, request, model_admin):
  44         return (
  45             ('on_release', 'Release'),
  46             ('on_esr', 'ESR'),
  47             ('on_beta', 'Beta'),
  48             ('on_aurora', 'Dev (Aurora)'),
  49             ('on_nightly', 'Nightly'),
  50         )
  51 
  52     def queryset(self, request, queryset):
  53         if self.value() is None:
  54             return queryset
  55 
  56         return queryset.filter(**{self.value(): True})
  57 
  58 
  59 class ActivityStreamFilter(admin.SimpleListFilter):
  60     title = 'Activity Stream'
  61     parameter_name = 'is_activity_stream'
  62 
  63     def lookups(self, request, model_admin):
  64         return (
  65             ('yes', 'Yes'),
  66             ('no', 'No'),
  67         )
  68 
  69     def queryset(self, request, queryset):
  70         if self.value() is None:
  71             return queryset
  72         elif self.value() == 'yes':
  73             return queryset.filter(on_startpage_5=True)
  74         elif self.value() == 'no':
  75             return queryset.exclude(on_startpage_5=True)
  76
  [end of snippets/base/admin/filters.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/snippets/base/admin/filters.py b/snippets/base/admin/filters.py
  --- a/snippets/base/admin/filters.py
  +++ b/snippets/base/admin/filters.py
  @@ -3,6 +3,8 @@
   from django.contrib import admin
   from django.utils.encoding import force_text
   
  +from snippets.base.managers import SnippetQuerySet
  +
   
   class ModifiedFilter(admin.SimpleListFilter):
       title = 'Last modified'
  @@ -53,7 +55,9 @@
           if self.value() is None:
               return queryset
   
  -        return queryset.filter(**{self.value(): True})
  +        if isinstance(queryset, SnippetQuerySet):
  +            return queryset.filter(**{self.value(): True})
  +        return queryset.filter(**{f'target__{self.value()}': True})
   
   
   class ActivityStreamFilter(admin.SimpleListFilter):
  
verification_info: {"golden_diff": "diff --git a/snippets/base/admin/filters.py b/snippets/base/admin/filters.py\n--- a/snippets/base/admin/filters.py\n+++ b/snippets/base/admin/filters.py\n@@ -3,6 +3,8 @@\n from django.contrib import admin\n from django.utils.encoding import force_text\n \n+from snippets.base.managers import SnippetQuerySet\n+\n \n class ModifiedFilter(admin.SimpleListFilter):\n     title = 'Last modified'\n@@ -53,7 +55,9 @@\n         if self.value() is None:\n             return queryset\n \n-        return queryset.filter(**{self.value(): True})\n+        if isinstance(queryset, SnippetQuerySet):\n+            return queryset.filter(**{self.value(): True})\n+        return queryset.filter(**{f'target__{self.value()}': True})\n \n \n class ActivityStreamFilter(admin.SimpleListFilter):\n", "issue": "Filter by release channel on ASRSnippets raises an error\n\n", "before_files": [{"content": "from datetime import datetime, timedelta\n\nfrom django.contrib import admin\nfrom django.utils.encoding import force_text\n\n\nclass ModifiedFilter(admin.SimpleListFilter):\n    title = 'Last modified'\n    parameter_name = 'last_modified'\n\n    def lookups(self, request, model_admin):\n        return (\n            ('24', '24 hours'),\n            ('168', '7 days'),\n            ('336', '14 days'),\n            ('720', '30 days'),\n            ('all', 'All'),\n        )\n\n    def queryset(self, request, queryset):\n        value = self.value()\n        if not value or value == 'all':\n            return queryset\n\n        when = datetime.utcnow() - timedelta(hours=int(value))\n        return queryset.exclude(modified__lt=when)\n\n    def choices(self, cl):\n        for lookup, title in self.lookup_choices:\n            yield {\n                'selected': self.value() == force_text(lookup),\n                'query_string': cl.get_query_string({\n                    self.parameter_name: lookup,\n                }, []),\n                'display': title,\n            }\n\n\nclass ChannelFilter(admin.SimpleListFilter):\n    title = 'Channel'\n    parameter_name = 'channel'\n\n    def lookups(self, request, model_admin):\n        return (\n            ('on_release', 'Release'),\n            ('on_esr', 'ESR'),\n            ('on_beta', 'Beta'),\n            ('on_aurora', 'Dev (Aurora)'),\n            ('on_nightly', 'Nightly'),\n        )\n\n    def queryset(self, request, queryset):\n        if self.value() is None:\n            return queryset\n\n        return queryset.filter(**{self.value(): True})\n\n\nclass ActivityStreamFilter(admin.SimpleListFilter):\n    title = 'Activity Stream'\n    parameter_name = 'is_activity_stream'\n\n    def lookups(self, request, model_admin):\n        return (\n            ('yes', 'Yes'),\n            ('no', 'No'),\n        )\n\n    def queryset(self, request, queryset):\n        if self.value() is None:\n            return queryset\n        elif self.value() == 'yes':\n            return queryset.filter(on_startpage_5=True)\n        elif self.value() == 'no':\n            return queryset.exclude(on_startpage_5=True)\n", "path": "snippets/base/admin/filters.py"}]}