We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add content_owner to organisation REST API filters


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `akvo/rest/views/organisation.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Akvo RSR is covered by the GNU Affero General Public License.
4 # See more details in the license.txt file located at the root folder of the Akvo RSR module.
5 # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
6 
7 from django.conf import settings
8 
9 from rest_framework.compat import etree, six
10 from rest_framework.exceptions import ParseError
11 from rest_framework.parsers import XMLParser, JSONParser
12 
13 from akvo.rsr.models import Organisation, Country
14 
15 from ..serializers import OrganisationSerializer
16 from ..viewsets import BaseRSRViewSet
17 
18 
19 class AkvoOrganisationParser(XMLParser):
20     def parse(self, stream, media_type=None, parser_context=None):
21         assert etree, 'XMLParser requires defusedxml to be installed'
22 
23         parser_context = parser_context or {}
24         encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
25         parser = etree.DefusedXMLParser(encoding=encoding)
26         try:
27             tree = etree.parse(stream, parser=parser, forbid_dtd=True)
28         except (etree.ParseError, ValueError) as exc:
29             raise ParseError('XML parse error - %s' % six.text_type(exc))
30         return self.organisation_data_from_etree(tree.getroot())
31 
32     def organisation_data_from_etree(self, tree):
33         def find_text(tree, str):
34             element = tree.find(str)
35             if element is None:
36                 return ''
37             return element.text.strip() if element.text else ""
38 
39         def location_data(location_tree):
40             if location_tree is None:
41                 return []
42             iso_code = find_text(location_tree, 'iso_code').lower()
43             country, created = Country.objects.get_or_create(**Country.fields_from_iso_code(iso_code))
44             country = country.id
45             latitude = find_text(location_tree, 'latitude') or 0
46             longitude = find_text(location_tree, 'longitude') or 0
47             primary = True
48             return [dict(latitude=latitude, longitude=longitude, country=country, primary=primary)]
49 
50         #id = find_text(tree, 'org_id')
51         long_name = find_text(tree, 'name')
52         name = long_name[:25]
53         description = find_text(tree, 'description')
54         url = find_text(tree, 'url')
55         iati_type = find_text(tree, 'iati_organisation_type')
56         new_organisation_type = int(iati_type) if iati_type else 22
57         organisation_type = Organisation.org_type_from_iati_type(new_organisation_type)
58         locations = location_data(tree.find('location/object'))
59         return dict(
60             name=name, long_name=long_name, description=description, url=url,
61             organisation_type=organisation_type, new_organisation_type=new_organisation_type,
62             locations=locations
63         )
64 
65 
66 class OrganisationViewSet(BaseRSRViewSet):
67     """
68     API endpoint that allows organisations to be viewed or edited.
69     """
70     queryset = Organisation.objects.all()
71     serializer_class = OrganisationSerializer
72     parser_classes = (AkvoOrganisationParser, JSONParser,)
73     filter_fields = ('name', 'long_name', 'iati_org_id', )
74 
75     def get_queryset(self):
76         """ Enable filtering of Organisations on iati_org_id or name
77         """
78         queryset = super(OrganisationViewSet, self).get_queryset()
79         pk = self.request.QUERY_PARAMS.get('id', None)
80         if pk is not None:
81             try:
82                 queryset = queryset.filter(pk=pk)
83             except ValueError:
84                 pass
85         iati_org_id = self.request.QUERY_PARAMS.get('iati_org_id', None)
86         if iati_org_id is not None:
87             queryset = queryset.filter(iati_org_id=iati_org_id)
88         name = self.request.QUERY_PARAMS.get('name', None)
89         if name is not None:
90             queryset = queryset.filter(name=name)
91         long_name = self.request.QUERY_PARAMS.get('long_name', None)
92         if long_name is not None:
93             queryset = queryset.filter(long_name=long_name)
94         return queryset
95
```
--- 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()

```

diff --git a/akvo/rest/views/organisation.py b/akvo/rest/views/organisation.py
--- a/akvo/rest/views/organisation.py
+++ b/akvo/rest/views/organisation.py
@@ -70,7 +70,7 @@
     queryset = Organisation.objects.all()
     serializer_class = OrganisationSerializer
     parser_classes = (AkvoOrganisationParser, JSONParser,)
-    filter_fields = ('name', 'long_name', 'iati_org_id', )
+    filter_fields = ('name', 'long_name', 'iati_org_id', 'content_owner')
 
     def get_queryset(self):
         """ Enable filtering of Organisations on iati_org_id or name

{"golden_diff": "diff --git a/akvo/rest/views/organisation.py b/akvo/rest/views/organisation.py\n--- a/akvo/rest/views/organisation.py\n+++ b/akvo/rest/views/organisation.py\n@@ -70,7 +70,7 @@\n     queryset = Organisation.objects.all()\n     serializer_class = OrganisationSerializer\n     parser_classes = (AkvoOrganisationParser, JSONParser,)\n-    filter_fields = ('name', 'long_name', 'iati_org_id', )\n+    filter_fields = ('name', 'long_name', 'iati_org_id', 'content_owner')\n \n     def get_queryset(self):\n         \"\"\" Enable filtering of Organisations on iati_org_id or name\n", "issue": "Add content_owner to organisation REST API filters\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo RSR is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\nfrom django.conf import settings\n\nfrom rest_framework.compat import etree, six\nfrom rest_framework.exceptions import ParseError\nfrom rest_framework.parsers import XMLParser, JSONParser\n\nfrom akvo.rsr.models import Organisation, Country\n\nfrom ..serializers import OrganisationSerializer\nfrom ..viewsets import BaseRSRViewSet\n\n\nclass AkvoOrganisationParser(XMLParser):\n    def parse(self, stream, media_type=None, parser_context=None):\n        assert etree, 'XMLParser requires defusedxml to be installed'\n\n        parser_context = parser_context or {}\n        encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)\n        parser = etree.DefusedXMLParser(encoding=encoding)\n        try:\n            tree = etree.parse(stream, parser=parser, forbid_dtd=True)\n        except (etree.ParseError, ValueError) as exc:\n            raise ParseError('XML parse error - %s' % six.text_type(exc))\n        return self.organisation_data_from_etree(tree.getroot())\n\n    def organisation_data_from_etree(self, tree):\n        def find_text(tree, str):\n            element = tree.find(str)\n            if element is None:\n                return ''\n            return element.text.strip() if element.text else \"\"\n\n        def location_data(location_tree):\n            if location_tree is None:\n                return []\n            iso_code = find_text(location_tree, 'iso_code').lower()\n            country, created = Country.objects.get_or_create(**Country.fields_from_iso_code(iso_code))\n            country = country.id\n            latitude = find_text(location_tree, 'latitude') or 0\n            longitude = find_text(location_tree, 'longitude') or 0\n            primary = True\n            return [dict(latitude=latitude, longitude=longitude, country=country, primary=primary)]\n\n        #id = find_text(tree, 'org_id')\n        long_name = find_text(tree, 'name')\n        name = long_name[:25]\n        description = find_text(tree, 'description')\n        url = find_text(tree, 'url')\n        iati_type = find_text(tree, 'iati_organisation_type')\n        new_organisation_type = int(iati_type) if iati_type else 22\n        organisation_type = Organisation.org_type_from_iati_type(new_organisation_type)\n        locations = location_data(tree.find('location/object'))\n        return dict(\n            name=name, long_name=long_name, description=description, url=url,\n            organisation_type=organisation_type, new_organisation_type=new_organisation_type,\n            locations=locations\n        )\n\n\nclass OrganisationViewSet(BaseRSRViewSet):\n    \"\"\"\n    API endpoint that allows organisations to be viewed or edited.\n    \"\"\"\n    queryset = Organisation.objects.all()\n    serializer_class = OrganisationSerializer\n    parser_classes = (AkvoOrganisationParser, JSONParser,)\n    filter_fields = ('name', 'long_name', 'iati_org_id', )\n\n    def get_queryset(self):\n        \"\"\" Enable filtering of Organisations on iati_org_id or name\n        \"\"\"\n        queryset = super(OrganisationViewSet, self).get_queryset()\n        pk = self.request.QUERY_PARAMS.get('id', None)\n        if pk is not None:\n            try:\n                queryset = queryset.filter(pk=pk)\n            except ValueError:\n                pass\n        iati_org_id = self.request.QUERY_PARAMS.get('iati_org_id', None)\n        if iati_org_id is not None:\n            queryset = queryset.filter(iati_org_id=iati_org_id)\n        name = self.request.QUERY_PARAMS.get('name', None)\n        if name is not None:\n            queryset = queryset.filter(name=name)\n        long_name = self.request.QUERY_PARAMS.get('long_name', None)\n        if long_name is not None:\n            queryset = queryset.filter(long_name=long_name)\n        return queryset\n", "path": "akvo/rest/views/organisation.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo RSR is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\nfrom django.conf import settings\n\nfrom rest_framework.compat import etree, six\nfrom rest_framework.exceptions import ParseError\nfrom rest_framework.parsers import XMLParser, JSONParser\n\nfrom akvo.rsr.models import Organisation, Country\n\nfrom ..serializers import OrganisationSerializer\nfrom ..viewsets import BaseRSRViewSet\n\n\nclass AkvoOrganisationParser(XMLParser):\n    def parse(self, stream, media_type=None, parser_context=None):\n        assert etree, 'XMLParser requires defusedxml to be installed'\n\n        parser_context = parser_context or {}\n        encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)\n        parser = etree.DefusedXMLParser(encoding=encoding)\n        try:\n            tree = etree.parse(stream, parser=parser, forbid_dtd=True)\n        except (etree.ParseError, ValueError) as exc:\n            raise ParseError('XML parse error - %s' % six.text_type(exc))\n        return self.organisation_data_from_etree(tree.getroot())\n\n    def organisation_data_from_etree(self, tree):\n        def find_text(tree, str):\n            element = tree.find(str)\n            if element is None:\n                return ''\n            return element.text.strip() if element.text else \"\"\n\n        def location_data(location_tree):\n            if location_tree is None:\n                return []\n            iso_code = find_text(location_tree, 'iso_code').lower()\n            country, created = Country.objects.get_or_create(**Country.fields_from_iso_code(iso_code))\n            country = country.id\n            latitude = find_text(location_tree, 'latitude') or 0\n            longitude = find_text(location_tree, 'longitude') or 0\n            primary = True\n            return [dict(latitude=latitude, longitude=longitude, country=country, primary=primary)]\n\n        #id = find_text(tree, 'org_id')\n        long_name = find_text(tree, 'name')\n        name = long_name[:25]\n        description = find_text(tree, 'description')\n        url = find_text(tree, 'url')\n        iati_type = find_text(tree, 'iati_organisation_type')\n        new_organisation_type = int(iati_type) if iati_type else 22\n        organisation_type = Organisation.org_type_from_iati_type(new_organisation_type)\n        locations = location_data(tree.find('location/object'))\n        return dict(\n            name=name, long_name=long_name, description=description, url=url,\n            organisation_type=organisation_type, new_organisation_type=new_organisation_type,\n            locations=locations\n        )\n\n\nclass OrganisationViewSet(BaseRSRViewSet):\n    \"\"\"\n    API endpoint that allows organisations to be viewed or edited.\n    \"\"\"\n    queryset = Organisation.objects.all()\n    serializer_class = OrganisationSerializer\n    parser_classes = (AkvoOrganisationParser, JSONParser,)\n    filter_fields = ('name', 'long_name', 'iati_org_id', 'content_owner')\n\n    def get_queryset(self):\n        \"\"\" Enable filtering of Organisations on iati_org_id or name\n        \"\"\"\n        queryset = super(OrganisationViewSet, self).get_queryset()\n        pk = self.request.QUERY_PARAMS.get('id', None)\n        if pk is not None:\n            try:\n                queryset = queryset.filter(pk=pk)\n            except ValueError:\n                pass\n        iati_org_id = self.request.QUERY_PARAMS.get('iati_org_id', None)\n        if iati_org_id is not None:\n            queryset = queryset.filter(iati_org_id=iati_org_id)\n        name = self.request.QUERY_PARAMS.get('name', None)\n        if name is not None:\n            queryset = queryset.filter(name=name)\n        long_name = self.request.QUERY_PARAMS.get('long_name', None)\n        if long_name is not None:\n            queryset = queryset.filter(long_name=long_name)\n        return queryset\n", "path": "akvo/rest/views/organisation.py"}]}