prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Instructor Selection: Additional filter/sort options for Admin view 
  On the Instructor Selection [admin view page](https://test-amy.carpentries.org/recruitment/processes/), the admin user can filter by assigned to and by status (open/closed).
  
  We would like to see the following additional options:
  
  * Filter by Online/in-person
  * Sort by Priority ascending and descending
  * Sort by date ascending and descending 
  * Filter by curriculum
  * Filter by country 
  
  
  </issue>
  <code>
  [start of amy/recruitment/filters.py]
  1 import django_filters
  2 
  3 from workshops.fields import ModelSelect2Widget
  4 from workshops.filters import AMYFilterSet
  5 from workshops.forms import SELECT2_SIDEBAR
  6 from workshops.models import Person
  7 
  8 from .models import InstructorRecruitment
  9 
  10 
  11 class InstructorRecruitmentFilter(AMYFilterSet):
  12     assigned_to = django_filters.ModelChoiceFilter(
  13         queryset=Person.objects.all(),
  14         widget=ModelSelect2Widget(data_view="admin-lookup", attrs=SELECT2_SIDEBAR),
  15     )
  16 
  17     class Meta:
  18         model = InstructorRecruitment
  19         fields = [
  20             "assigned_to",
  21             "status",
  22         ]
  23
  [end of amy/recruitment/filters.py]
  [start of amy/dashboard/filters.py]
  1 from django.db.models import F, QuerySet
  2 from django.forms import widgets
  3 import django_filters as filters
  4 
  5 from recruitment.models import InstructorRecruitment
  6 from workshops.filters import AMYFilterSet
  7 
  8 
  9 class UpcomingTeachingOpportunitiesFilter(AMYFilterSet):
  10     status = filters.ChoiceFilter(
  11         choices=(
  12             ("online", "Online only"),
  13             ("inperson", "Inperson only"),
  14         ),
  15         empty_label="Any",
  16         label="Online/inperson",
  17         method="filter_status",
  18     )
  19 
  20     only_applied_to = filters.BooleanFilter(
  21         label="Show only workshops I have applied to",
  22         method="filter_application_only",
  23         widget=widgets.CheckboxInput,
  24     )
  25 
  26     order_by = filters.OrderingFilter(
  27         fields=("event__start",),
  28         choices=(
  29             ("-calculated_priority", "Priority"),
  30             ("event__start", "Event start"),
  31             ("-event__start", "Event start (descending)"),
  32             ("proximity", "Closer to my airport"),
  33             ("-proximity", "Further away from my airport"),
  34         ),
  35         method="filter_order_by",
  36     )
  37 
  38     class Meta:
  39         model = InstructorRecruitment
  40         fields = [
  41             "status",
  42         ]
  43 
  44     def filter_status(self, queryset: QuerySet, name: str, value: str) -> QuerySet:
  45         """Filter recruitments based on the event (online/inperson) status."""
  46         if value == "online":
  47             return queryset.filter(event__tags__name="online")
  48         elif value == "inperson":
  49             return queryset.exclude(event__tags__name="online")
  50         else:
  51             return queryset
  52 
  53     def filter_order_by(self, queryset: QuerySet, name: str, values: list) -> QuerySet:
  54         """Order entries by proximity to user's airport."""
  55         try:
  56             latitude: float = self.request.user.airport.latitude
  57         except AttributeError:
  58             latitude = 0.0
  59 
  60         try:
  61             longitude: float = self.request.user.airport.longitude
  62         except AttributeError:
  63             longitude = 0.0
  64 
  65         # `0.0` is neutral element for this equation, so even if user doesn't have the
  66         # airport specified, the sorting should still work
  67         distance = (F("event__latitude") - latitude) ** 2.0 + (
  68             F("event__longitude") - longitude
  69         ) ** 2.0
  70 
  71         if values == ["proximity"]:
  72             return queryset.annotate(distance=distance).order_by("distance")
  73         elif values == ["-proximity"]:
  74             return queryset.annotate(distance=distance).order_by("-distance")
  75         else:
  76             return queryset.order_by(*values)
  77 
  78     def filter_application_only(
  79         self, queryset: QuerySet, name: str, value: bool
  80     ) -> QuerySet:
  81         if value:
  82             return queryset.filter(signups__person=self.request.user)
  83 
  84         return queryset
  85
  [end of amy/dashboard/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/amy/dashboard/filters.py b/amy/dashboard/filters.py
  --- a/amy/dashboard/filters.py
  +++ b/amy/dashboard/filters.py
  @@ -3,7 +3,9 @@
   import django_filters as filters
   
   from recruitment.models import InstructorRecruitment
  -from workshops.filters import AMYFilterSet
  +from workshops.fields import Select2MultipleWidget
  +from workshops.filters import AllCountriesMultipleFilter, AMYFilterSet
  +from workshops.models import Curriculum
   
   
   class UpcomingTeachingOpportunitiesFilter(AMYFilterSet):
  @@ -23,6 +25,17 @@
           widget=widgets.CheckboxInput,
       )
   
  +    country = AllCountriesMultipleFilter(
  +        field_name="event__country", widget=Select2MultipleWidget
  +    )
  +
  +    curricula = filters.ModelMultipleChoiceFilter(
  +        field_name="event__curricula",
  +        queryset=Curriculum.objects.all(),
  +        label="Curriculum",
  +        widget=Select2MultipleWidget(),
  +    )
  +
       order_by = filters.OrderingFilter(
           fields=("event__start",),
           choices=(
  diff --git a/amy/recruitment/filters.py b/amy/recruitment/filters.py
  --- a/amy/recruitment/filters.py
  +++ b/amy/recruitment/filters.py
  @@ -1,22 +1,68 @@
  -import django_filters
  +from django.db.models import QuerySet
  +import django_filters as filters
   
  -from workshops.fields import ModelSelect2Widget
  -from workshops.filters import AMYFilterSet
  +from workshops.fields import ModelSelect2Widget, Select2MultipleWidget
  +from workshops.filters import AllCountriesMultipleFilter, AMYFilterSet
   from workshops.forms import SELECT2_SIDEBAR
  -from workshops.models import Person
  +from workshops.models import Curriculum, Person
   
   from .models import InstructorRecruitment
   
   
   class InstructorRecruitmentFilter(AMYFilterSet):
  -    assigned_to = django_filters.ModelChoiceFilter(
  +    assigned_to = filters.ModelChoiceFilter(
           queryset=Person.objects.all(),
           widget=ModelSelect2Widget(data_view="admin-lookup", attrs=SELECT2_SIDEBAR),
       )
   
  +    online_inperson = filters.ChoiceFilter(
  +        choices=(
  +            ("online", "Online only"),
  +            ("inperson", "Inperson only"),
  +        ),
  +        empty_label="Any",
  +        label="Online/inperson",
  +        method="filter_online_inperson",
  +    )
  +
  +    country = AllCountriesMultipleFilter(
  +        field_name="event__country", widget=Select2MultipleWidget
  +    )
  +
  +    curricula = filters.ModelMultipleChoiceFilter(
  +        field_name="event__curricula",
  +        queryset=Curriculum.objects.all(),
  +        label="Curriculum",
  +        widget=Select2MultipleWidget(),
  +    )
  +
  +    order_by = filters.OrderingFilter(
  +        fields=("event__start",),
  +        choices=(
  +            ("-calculated_priority", "Priority"),
  +            ("event__start", "Event start"),
  +            ("-event__start", "Event start (descending)"),
  +        ),
  +        method="filter_order_by",
  +    )
  +
       class Meta:
           model = InstructorRecruitment
           fields = [
               "assigned_to",
               "status",
           ]
  +
  +    def filter_online_inperson(
  +        self, queryset: QuerySet, name: str, value: str
  +    ) -> QuerySet:
  +        """Filter recruitments based on the event (online/inperson) status."""
  +        if value == "online":
  +            return queryset.filter(event__tags__name="online")
  +        elif value == "inperson":
  +            return queryset.exclude(event__tags__name="online")
  +        else:
  +            return queryset
  +
  +    def filter_order_by(self, queryset: QuerySet, name: str, values: list) -> QuerySet:
  +        return queryset.order_by(*values)
  
verification_info: {"golden_diff": "diff --git a/amy/dashboard/filters.py b/amy/dashboard/filters.py\n--- a/amy/dashboard/filters.py\n+++ b/amy/dashboard/filters.py\n@@ -3,7 +3,9 @@\n import django_filters as filters\n \n from recruitment.models import InstructorRecruitment\n-from workshops.filters import AMYFilterSet\n+from workshops.fields import Select2MultipleWidget\n+from workshops.filters import AllCountriesMultipleFilter, AMYFilterSet\n+from workshops.models import Curriculum\n \n \n class UpcomingTeachingOpportunitiesFilter(AMYFilterSet):\n@@ -23,6 +25,17 @@\n         widget=widgets.CheckboxInput,\n     )\n \n+    country = AllCountriesMultipleFilter(\n+        field_name=\"event__country\", widget=Select2MultipleWidget\n+    )\n+\n+    curricula = filters.ModelMultipleChoiceFilter(\n+        field_name=\"event__curricula\",\n+        queryset=Curriculum.objects.all(),\n+        label=\"Curriculum\",\n+        widget=Select2MultipleWidget(),\n+    )\n+\n     order_by = filters.OrderingFilter(\n         fields=(\"event__start\",),\n         choices=(\ndiff --git a/amy/recruitment/filters.py b/amy/recruitment/filters.py\n--- a/amy/recruitment/filters.py\n+++ b/amy/recruitment/filters.py\n@@ -1,22 +1,68 @@\n-import django_filters\n+from django.db.models import QuerySet\n+import django_filters as filters\n \n-from workshops.fields import ModelSelect2Widget\n-from workshops.filters import AMYFilterSet\n+from workshops.fields import ModelSelect2Widget, Select2MultipleWidget\n+from workshops.filters import AllCountriesMultipleFilter, AMYFilterSet\n from workshops.forms import SELECT2_SIDEBAR\n-from workshops.models import Person\n+from workshops.models import Curriculum, Person\n \n from .models import InstructorRecruitment\n \n \n class InstructorRecruitmentFilter(AMYFilterSet):\n-    assigned_to = django_filters.ModelChoiceFilter(\n+    assigned_to = filters.ModelChoiceFilter(\n         queryset=Person.objects.all(),\n         widget=ModelSelect2Widget(data_view=\"admin-lookup\", attrs=SELECT2_SIDEBAR),\n     )\n \n+    online_inperson = filters.ChoiceFilter(\n+        choices=(\n+            (\"online\", \"Online only\"),\n+            (\"inperson\", \"Inperson only\"),\n+        ),\n+        empty_label=\"Any\",\n+        label=\"Online/inperson\",\n+        method=\"filter_online_inperson\",\n+    )\n+\n+    country = AllCountriesMultipleFilter(\n+        field_name=\"event__country\", widget=Select2MultipleWidget\n+    )\n+\n+    curricula = filters.ModelMultipleChoiceFilter(\n+        field_name=\"event__curricula\",\n+        queryset=Curriculum.objects.all(),\n+        label=\"Curriculum\",\n+        widget=Select2MultipleWidget(),\n+    )\n+\n+    order_by = filters.OrderingFilter(\n+        fields=(\"event__start\",),\n+        choices=(\n+            (\"-calculated_priority\", \"Priority\"),\n+            (\"event__start\", \"Event start\"),\n+            (\"-event__start\", \"Event start (descending)\"),\n+        ),\n+        method=\"filter_order_by\",\n+    )\n+\n     class Meta:\n         model = InstructorRecruitment\n         fields = [\n             \"assigned_to\",\n             \"status\",\n         ]\n+\n+    def filter_online_inperson(\n+        self, queryset: QuerySet, name: str, value: str\n+    ) -> QuerySet:\n+        \"\"\"Filter recruitments based on the event (online/inperson) status.\"\"\"\n+        if value == \"online\":\n+            return queryset.filter(event__tags__name=\"online\")\n+        elif value == \"inperson\":\n+            return queryset.exclude(event__tags__name=\"online\")\n+        else:\n+            return queryset\n+\n+    def filter_order_by(self, queryset: QuerySet, name: str, values: list) -> QuerySet:\n+        return queryset.order_by(*values)\n", "issue": "Instructor Selection: Additional filter/sort options for Admin view \nOn the Instructor Selection [admin view page](https://test-amy.carpentries.org/recruitment/processes/), the admin user can filter by assigned to and by status (open/closed).\r\n\r\nWe would like to see the following additional options:\r\n\r\n* Filter by Online/in-person\r\n* Sort by Priority ascending and descending\r\n* Sort by date ascending and descending \r\n* Filter by curriculum\r\n* Filter by country \r\n\n", "before_files": [{"content": "import django_filters\n\nfrom workshops.fields import ModelSelect2Widget\nfrom workshops.filters import AMYFilterSet\nfrom workshops.forms import SELECT2_SIDEBAR\nfrom workshops.models import Person\n\nfrom .models import InstructorRecruitment\n\n\nclass InstructorRecruitmentFilter(AMYFilterSet):\n    assigned_to = django_filters.ModelChoiceFilter(\n        queryset=Person.objects.all(),\n        widget=ModelSelect2Widget(data_view=\"admin-lookup\", attrs=SELECT2_SIDEBAR),\n    )\n\n    class Meta:\n        model = InstructorRecruitment\n        fields = [\n            \"assigned_to\",\n            \"status\",\n        ]\n", "path": "amy/recruitment/filters.py"}, {"content": "from django.db.models import F, QuerySet\nfrom django.forms import widgets\nimport django_filters as filters\n\nfrom recruitment.models import InstructorRecruitment\nfrom workshops.filters import AMYFilterSet\n\n\nclass UpcomingTeachingOpportunitiesFilter(AMYFilterSet):\n    status = filters.ChoiceFilter(\n        choices=(\n            (\"online\", \"Online only\"),\n            (\"inperson\", \"Inperson only\"),\n        ),\n        empty_label=\"Any\",\n        label=\"Online/inperson\",\n        method=\"filter_status\",\n    )\n\n    only_applied_to = filters.BooleanFilter(\n        label=\"Show only workshops I have applied to\",\n        method=\"filter_application_only\",\n        widget=widgets.CheckboxInput,\n    )\n\n    order_by = filters.OrderingFilter(\n        fields=(\"event__start\",),\n        choices=(\n            (\"-calculated_priority\", \"Priority\"),\n            (\"event__start\", \"Event start\"),\n            (\"-event__start\", \"Event start (descending)\"),\n            (\"proximity\", \"Closer to my airport\"),\n            (\"-proximity\", \"Further away from my airport\"),\n        ),\n        method=\"filter_order_by\",\n    )\n\n    class Meta:\n        model = InstructorRecruitment\n        fields = [\n            \"status\",\n        ]\n\n    def filter_status(self, queryset: QuerySet, name: str, value: str) -> QuerySet:\n        \"\"\"Filter recruitments based on the event (online/inperson) status.\"\"\"\n        if value == \"online\":\n            return queryset.filter(event__tags__name=\"online\")\n        elif value == \"inperson\":\n            return queryset.exclude(event__tags__name=\"online\")\n        else:\n            return queryset\n\n    def filter_order_by(self, queryset: QuerySet, name: str, values: list) -> QuerySet:\n        \"\"\"Order entries by proximity to user's airport.\"\"\"\n        try:\n            latitude: float = self.request.user.airport.latitude\n        except AttributeError:\n            latitude = 0.0\n\n        try:\n            longitude: float = self.request.user.airport.longitude\n        except AttributeError:\n            longitude = 0.0\n\n        # `0.0` is neutral element for this equation, so even if user doesn't have the\n        # airport specified, the sorting should still work\n        distance = (F(\"event__latitude\") - latitude) ** 2.0 + (\n            F(\"event__longitude\") - longitude\n        ) ** 2.0\n\n        if values == [\"proximity\"]:\n            return queryset.annotate(distance=distance).order_by(\"distance\")\n        elif values == [\"-proximity\"]:\n            return queryset.annotate(distance=distance).order_by(\"-distance\")\n        else:\n            return queryset.order_by(*values)\n\n    def filter_application_only(\n        self, queryset: QuerySet, name: str, value: bool\n    ) -> QuerySet:\n        if value:\n            return queryset.filter(signups__person=self.request.user)\n\n        return queryset\n", "path": "amy/dashboard/filters.py"}]}