prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Project up REST resource broken
  ## Test plan
  
  The `/rest/v1/project_up/` resource should not give an error.
  ## Sentry
  
  See http://sentry.support.akvo-ops.org/rsr/live/group/743/
  
  
  --- 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/project.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 """Akvo RSR is covered by the GNU Affero General Public License.
  3 
  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 
  8 from akvo.rest.serializers.project import ProjectUpSerializer
  9 from akvo.rsr.models import Project
  10 from ..serializers import ProjectSerializer, ProjectExtraSerializer
  11 from ..viewsets import BaseRSRViewSet
  12 
  13 
  14 class ProjectViewSet(BaseRSRViewSet):
  15 
  16     """
  17     Viewset providing Project data.
  18 
  19     Allowed parameters are:
  20     __limit__ (default 30, max 100),
  21     __title__ (exact or icontains),
  22     __subtitle__ (exact or icontains),
  23     __status__,
  24     __language__,
  25     __currency__,
  26     __date_start_planned__ (exact, gt, gte, lt or lte),
  27     __date_start_actual__ (exact, gt, gte, lt or lte),
  28     __date_end_planned__ (exact, gt, gte, lt or lte),
  29     __date_end_actual__ (exact, gt, gte, lt or lte),
  30     __created_at__ (exact, gt, gte, lt or lte),
  31     __last_modified_at__ (exact, gt, gte, lt or lte),
  32     __sync_owner__,
  33     __iati_activity_id__ (exact or icontains),
  34     __hierarchy__,
  35     __project_scope__,
  36     __collaboration_type__,
  37     __default_aid_type__,
  38     __default_finance_type__,
  39     __default_flow_type__,
  40     __default_tied_status__,
  41     __budget__ (exact, gt, gte, lt or lte),
  42     __funds__ (exact, gt, gte, lt or lte),
  43     __funds_needed__ (exact, gt, gte, lt or lte),
  44     __categories__ (exact, in),
  45     __partners__ (exact, in),
  46     __keywords__ (exact, in), and
  47     __publishingstatus\__status__.
  48     """
  49     queryset = Project.objects.select_related(
  50         'categories',
  51         'keywords',
  52         'partners',
  53     ).prefetch_related(
  54         'publishingstatus',
  55     )
  56 
  57     serializer_class = ProjectSerializer
  58     filter_fields = {
  59         'title': ['exact', 'icontains'],
  60         'subtitle': ['exact', 'icontains'],
  61         'status': ['exact', ],
  62         'language': ['exact', ],
  63         'currency': ['exact', ],
  64         'date_start_planned': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  65         'date_start_actual': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  66         'date_end_planned': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  67         'date_end_actual': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  68         'created_at': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  69         'last_modified_at': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  70         'iati_activity_id': ['exact', 'icontains', ],
  71         'hierarchy': ['exact', ],
  72         'project_scope': ['exact', ],
  73         'collaboration_type': ['exact', ],
  74         'default_aid_type': ['exact', ],
  75         'default_finance_type': ['exact', ],
  76         'default_flow_type': ['exact', ],
  77         'default_tied_status': ['exact', ],
  78         'budget': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  79         'funds': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  80         'funds_needed': ['exact', 'gt', 'gte', 'lt', 'lte', ],
  81         'categories': ['exact', 'in', ],
  82         'partners': ['exact', 'in', ],
  83         'keywords': ['exact', 'in', ],
  84         'publishingstatus__status': ['exact', ],
  85     }
  86 
  87     def get_queryset(self):
  88         """
  89         Allow custom filter for sync_owner, since this field has been replaced by the
  90         reporting org partnership.
  91         """
  92         queryset = self.queryset
  93         sync_owner = self.request.QUERY_PARAMS.get('sync_owner', None)
  94         if sync_owner:
  95             queryset = queryset.filter(partnerships__iati_organisation_role=101,
  96                                        partnerships__organisation__pk=sync_owner)
  97         return queryset.distinct()
  98 
  99 
  100 class ProjectExtraViewSet(ProjectViewSet):
  101 
  102     """
  103     Viewset providing extra Project data.
  104 
  105     Allowed parameters are:
  106     __limit__ (default 30, max 100),
  107     __partnerships\__organisation__ (filter on organisation ID), and
  108     __publishingstatus\__status__ (filter on publishing status)
  109     """
  110 
  111     queryset = Project.objects.public().prefetch_related(
  112         'publishingstatus',
  113         'sectors',
  114         'partnerships',
  115     )
  116     serializer_class = ProjectExtraSerializer
  117     paginate_by_param = 'limit'
  118     filter_fields = ('partnerships__organisation', 'publishingstatus__status')
  119 
  120 
  121 class ProjectUpViewSet(ProjectViewSet):
  122 
  123     """
  124     Viewset providing extra data and limited filtering for Up in one go.
  125 
  126     Allowed parameters are:
  127     __limit__ (default 30, max 100),
  128     __partnerships\__organisation__ (filter on organisation ID), and
  129     __publishingstatus\__status__ (filter on publishing status)
  130     """
  131 
  132     queryset = Project.objects.public().select_related(
  133         'primary_location',
  134         'categories',
  135         'keywords',
  136         'partners',
  137     ).prefetch_related(
  138         'publishingstatus',
  139         'updates',
  140     )
  141     serializer_class = ProjectUpSerializer
  142     paginate_by_param = 'limit'
  143     max_paginate_by = 100
  144     filter_fields = ('partnerships__organisation', 'publishingstatus__status')
  145
  ```
  --- 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/akvo/rest/views/project.py b/akvo/rest/views/project.py
  --- a/akvo/rest/views/project.py
  +++ b/akvo/rest/views/project.py
  @@ -136,7 +136,7 @@
           'partners',
       ).prefetch_related(
           'publishingstatus',
  -        'updates',
  +        'project_updates',
       )
       serializer_class = ProjectUpSerializer
       paginate_by_param = 'limit'
  
verification_info: {"golden_diff": "diff --git a/akvo/rest/views/project.py b/akvo/rest/views/project.py\n--- a/akvo/rest/views/project.py\n+++ b/akvo/rest/views/project.py\n@@ -136,7 +136,7 @@\n         'partners',\n     ).prefetch_related(\n         'publishingstatus',\n-        'updates',\n+        'project_updates',\n     )\n     serializer_class = ProjectUpSerializer\n     paginate_by_param = 'limit'\n", "issue": "Project up REST resource broken\n## Test plan\n\nThe `/rest/v1/project_up/` resource should not give an error.\n## Sentry\n\nSee http://sentry.support.akvo-ops.org/rsr/live/group/743/\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Akvo RSR is covered by the GNU Affero General Public License.\n\nSee more details in the license.txt file located at the root folder of the Akvo RSR module.\nFor additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\"\"\"\n\nfrom akvo.rest.serializers.project import ProjectUpSerializer\nfrom akvo.rsr.models import Project\nfrom ..serializers import ProjectSerializer, ProjectExtraSerializer\nfrom ..viewsets import BaseRSRViewSet\n\n\nclass ProjectViewSet(BaseRSRViewSet):\n\n    \"\"\"\n    Viewset providing Project data.\n\n    Allowed parameters are:\n    __limit__ (default 30, max 100),\n    __title__ (exact or icontains),\n    __subtitle__ (exact or icontains),\n    __status__,\n    __language__,\n    __currency__,\n    __date_start_planned__ (exact, gt, gte, lt or lte),\n    __date_start_actual__ (exact, gt, gte, lt or lte),\n    __date_end_planned__ (exact, gt, gte, lt or lte),\n    __date_end_actual__ (exact, gt, gte, lt or lte),\n    __created_at__ (exact, gt, gte, lt or lte),\n    __last_modified_at__ (exact, gt, gte, lt or lte),\n    __sync_owner__,\n    __iati_activity_id__ (exact or icontains),\n    __hierarchy__,\n    __project_scope__,\n    __collaboration_type__,\n    __default_aid_type__,\n    __default_finance_type__,\n    __default_flow_type__,\n    __default_tied_status__,\n    __budget__ (exact, gt, gte, lt or lte),\n    __funds__ (exact, gt, gte, lt or lte),\n    __funds_needed__ (exact, gt, gte, lt or lte),\n    __categories__ (exact, in),\n    __partners__ (exact, in),\n    __keywords__ (exact, in), and\n    __publishingstatus\\__status__.\n    \"\"\"\n    queryset = Project.objects.select_related(\n        'categories',\n        'keywords',\n        'partners',\n    ).prefetch_related(\n        'publishingstatus',\n    )\n\n    serializer_class = ProjectSerializer\n    filter_fields = {\n        'title': ['exact', 'icontains'],\n        'subtitle': ['exact', 'icontains'],\n        'status': ['exact', ],\n        'language': ['exact', ],\n        'currency': ['exact', ],\n        'date_start_planned': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'date_start_actual': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'date_end_planned': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'date_end_actual': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'created_at': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'last_modified_at': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'iati_activity_id': ['exact', 'icontains', ],\n        'hierarchy': ['exact', ],\n        'project_scope': ['exact', ],\n        'collaboration_type': ['exact', ],\n        'default_aid_type': ['exact', ],\n        'default_finance_type': ['exact', ],\n        'default_flow_type': ['exact', ],\n        'default_tied_status': ['exact', ],\n        'budget': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'funds': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'funds_needed': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'categories': ['exact', 'in', ],\n        'partners': ['exact', 'in', ],\n        'keywords': ['exact', 'in', ],\n        'publishingstatus__status': ['exact', ],\n    }\n\n    def get_queryset(self):\n        \"\"\"\n        Allow custom filter for sync_owner, since this field has been replaced by the\n        reporting org partnership.\n        \"\"\"\n        queryset = self.queryset\n        sync_owner = self.request.QUERY_PARAMS.get('sync_owner', None)\n        if sync_owner:\n            queryset = queryset.filter(partnerships__iati_organisation_role=101,\n                                       partnerships__organisation__pk=sync_owner)\n        return queryset.distinct()\n\n\nclass ProjectExtraViewSet(ProjectViewSet):\n\n    \"\"\"\n    Viewset providing extra Project data.\n\n    Allowed parameters are:\n    __limit__ (default 30, max 100),\n    __partnerships\\__organisation__ (filter on organisation ID), and\n    __publishingstatus\\__status__ (filter on publishing status)\n    \"\"\"\n\n    queryset = Project.objects.public().prefetch_related(\n        'publishingstatus',\n        'sectors',\n        'partnerships',\n    )\n    serializer_class = ProjectExtraSerializer\n    paginate_by_param = 'limit'\n    filter_fields = ('partnerships__organisation', 'publishingstatus__status')\n\n\nclass ProjectUpViewSet(ProjectViewSet):\n\n    \"\"\"\n    Viewset providing extra data and limited filtering for Up in one go.\n\n    Allowed parameters are:\n    __limit__ (default 30, max 100),\n    __partnerships\\__organisation__ (filter on organisation ID), and\n    __publishingstatus\\__status__ (filter on publishing status)\n    \"\"\"\n\n    queryset = Project.objects.public().select_related(\n        'primary_location',\n        'categories',\n        'keywords',\n        'partners',\n    ).prefetch_related(\n        'publishingstatus',\n        'updates',\n    )\n    serializer_class = ProjectUpSerializer\n    paginate_by_param = 'limit'\n    max_paginate_by = 100\n    filter_fields = ('partnerships__organisation', 'publishingstatus__status')\n", "path": "akvo/rest/views/project.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Akvo RSR is covered by the GNU Affero General Public License.\n\nSee more details in the license.txt file located at the root folder of the Akvo RSR module.\nFor additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\"\"\"\n\nfrom akvo.rest.serializers.project import ProjectUpSerializer\nfrom akvo.rsr.models import Project\nfrom ..serializers import ProjectSerializer, ProjectExtraSerializer\nfrom ..viewsets import BaseRSRViewSet\n\n\nclass ProjectViewSet(BaseRSRViewSet):\n\n    \"\"\"\n    Viewset providing Project data.\n\n    Allowed parameters are:\n    __limit__ (default 30, max 100),\n    __title__ (exact or icontains),\n    __subtitle__ (exact or icontains),\n    __status__,\n    __language__,\n    __currency__,\n    __date_start_planned__ (exact, gt, gte, lt or lte),\n    __date_start_actual__ (exact, gt, gte, lt or lte),\n    __date_end_planned__ (exact, gt, gte, lt or lte),\n    __date_end_actual__ (exact, gt, gte, lt or lte),\n    __created_at__ (exact, gt, gte, lt or lte),\n    __last_modified_at__ (exact, gt, gte, lt or lte),\n    __sync_owner__,\n    __iati_activity_id__ (exact or icontains),\n    __hierarchy__,\n    __project_scope__,\n    __collaboration_type__,\n    __default_aid_type__,\n    __default_finance_type__,\n    __default_flow_type__,\n    __default_tied_status__,\n    __budget__ (exact, gt, gte, lt or lte),\n    __funds__ (exact, gt, gte, lt or lte),\n    __funds_needed__ (exact, gt, gte, lt or lte),\n    __categories__ (exact, in),\n    __partners__ (exact, in),\n    __keywords__ (exact, in), and\n    __publishingstatus\\__status__.\n    \"\"\"\n    queryset = Project.objects.select_related(\n        'categories',\n        'keywords',\n        'partners',\n    ).prefetch_related(\n        'publishingstatus',\n    )\n\n    serializer_class = ProjectSerializer\n    filter_fields = {\n        'title': ['exact', 'icontains'],\n        'subtitle': ['exact', 'icontains'],\n        'status': ['exact', ],\n        'language': ['exact', ],\n        'currency': ['exact', ],\n        'date_start_planned': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'date_start_actual': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'date_end_planned': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'date_end_actual': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'created_at': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'last_modified_at': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'iati_activity_id': ['exact', 'icontains', ],\n        'hierarchy': ['exact', ],\n        'project_scope': ['exact', ],\n        'collaboration_type': ['exact', ],\n        'default_aid_type': ['exact', ],\n        'default_finance_type': ['exact', ],\n        'default_flow_type': ['exact', ],\n        'default_tied_status': ['exact', ],\n        'budget': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'funds': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'funds_needed': ['exact', 'gt', 'gte', 'lt', 'lte', ],\n        'categories': ['exact', 'in', ],\n        'partners': ['exact', 'in', ],\n        'keywords': ['exact', 'in', ],\n        'publishingstatus__status': ['exact', ],\n    }\n\n    def get_queryset(self):\n        \"\"\"\n        Allow custom filter for sync_owner, since this field has been replaced by the\n        reporting org partnership.\n        \"\"\"\n        queryset = self.queryset\n        sync_owner = self.request.QUERY_PARAMS.get('sync_owner', None)\n        if sync_owner:\n            queryset = queryset.filter(partnerships__iati_organisation_role=101,\n                                       partnerships__organisation__pk=sync_owner)\n        return queryset.distinct()\n\n\nclass ProjectExtraViewSet(ProjectViewSet):\n\n    \"\"\"\n    Viewset providing extra Project data.\n\n    Allowed parameters are:\n    __limit__ (default 30, max 100),\n    __partnerships\\__organisation__ (filter on organisation ID), and\n    __publishingstatus\\__status__ (filter on publishing status)\n    \"\"\"\n\n    queryset = Project.objects.public().prefetch_related(\n        'publishingstatus',\n        'sectors',\n        'partnerships',\n    )\n    serializer_class = ProjectExtraSerializer\n    paginate_by_param = 'limit'\n    filter_fields = ('partnerships__organisation', 'publishingstatus__status')\n\n\nclass ProjectUpViewSet(ProjectViewSet):\n\n    \"\"\"\n    Viewset providing extra data and limited filtering for Up in one go.\n\n    Allowed parameters are:\n    __limit__ (default 30, max 100),\n    __partnerships\\__organisation__ (filter on organisation ID), and\n    __publishingstatus\\__status__ (filter on publishing status)\n    \"\"\"\n\n    queryset = Project.objects.public().select_related(\n        'primary_location',\n        'categories',\n        'keywords',\n        'partners',\n    ).prefetch_related(\n        'publishingstatus',\n        'project_updates',\n    )\n    serializer_class = ProjectUpSerializer\n    paginate_by_param = 'limit'\n    max_paginate_by = 100\n    filter_fields = ('partnerships__organisation', 'publishingstatus__status')\n", "path": "akvo/rest/views/project.py"}]}