We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Project can only have one reporting organisation
## Test plan
1. Go to project editor and select 2 reporting organisations in section 3
2. _RESULT:_ a validation error should be shown
3. Remove one of the reporting organisations
4. _RESULT:_ the save should be successful
## Issue description

Validation error appears even if there's only one reporting organisation.


--- 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/rsr/models/partnership.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 
8 from django.core.exceptions import ValidationError
9 from django.db import models
10 from django.utils.translation import ugettext_lazy as _
11 
12 from ..fields import ValidXMLCharField
13 
14 
15 class Partnership(models.Model):
16     # the old way
17     FIELD_PARTNER = u'field'
18     FUNDING_PARTNER = u'funding'
19     SPONSOR_PARTNER = u'sponsor'
20     SUPPORT_PARTNER = u'support'
21     EXTENDING_PARTNER = u'extending'
22 
23     PARTNER_TYPE_LIST = [
24         FIELD_PARTNER, FUNDING_PARTNER, SPONSOR_PARTNER, SUPPORT_PARTNER, EXTENDING_PARTNER
25     ]
26     PARTNER_LABELS = [
27         _(u'Implementing partner'),
28         _(u'Funding partner'),
29         _(u'Sponsor partner'),
30         _(u'Accountable partner'),
31         _(u'Extending partner'),
32     ]
33     PARTNER_TYPES = zip(PARTNER_TYPE_LIST, PARTNER_LABELS)
34 
35     # the new way
36     IATI_FUNDING_PARTNER = 1
37     IATI_ACCOUNTABLE_PARTNER = 2
38     IATI_EXTENDING_PARTNER = 3
39     IATI_IMPLEMENTING_PARTNER = 4
40     AKVO_SPONSOR_PARTNER = 100   # not part of the IATI OrganisationRole codelist!
41     IATI_REPORTING_ORGANISATION = 101
42 
43     # make sure the AKVO_SPONSOR_PARTNER is last in the list
44     IATI_ROLE_LIST = [
45         IATI_FUNDING_PARTNER, IATI_ACCOUNTABLE_PARTNER, IATI_EXTENDING_PARTNER,
46         IATI_IMPLEMENTING_PARTNER, AKVO_SPONSOR_PARTNER, IATI_REPORTING_ORGANISATION
47     ]
48     IATI_ROLE_LABELS = [
49         _(u'Funding partner'),
50         _(u'Accountable partner'),
51         _(u'Extending partner'),
52         _(u'Implementing partner'),
53         _(u'Sponsor partner'),
54         _(u'Reporting organisation'),
55     ]
56     IATI_ROLES = zip(IATI_ROLE_LIST, IATI_ROLE_LABELS)
57 
58     # used when migrating
59     PARTNER_TYPES_TO_ROLES_MAP = {
60         FUNDING_PARTNER: IATI_FUNDING_PARTNER,
61         SUPPORT_PARTNER: IATI_ACCOUNTABLE_PARTNER,
62         FIELD_PARTNER: IATI_IMPLEMENTING_PARTNER,
63         SPONSOR_PARTNER: AKVO_SPONSOR_PARTNER,
64     }
65 
66     # backwards compatibility
67     ROLES_TO_PARTNER_TYPES_MAP = {
68         IATI_FUNDING_PARTNER: FUNDING_PARTNER,
69         IATI_ACCOUNTABLE_PARTNER: SUPPORT_PARTNER,
70         IATI_EXTENDING_PARTNER: EXTENDING_PARTNER,
71         IATI_IMPLEMENTING_PARTNER: FIELD_PARTNER,
72         AKVO_SPONSOR_PARTNER: SPONSOR_PARTNER,
73         # TODO: not backwards compatible
74         IATI_REPORTING_ORGANISATION: u''
75     }
76 
77     ALLIANCE_PARTNER = u'alliance'
78     KNOWLEDGE_PARTNER = u'knowledge'
79     NETWORK_PARTNER = u'network'
80 
81     PARTNER_TYPE_EXTRAS_LIST = (ALLIANCE_PARTNER, KNOWLEDGE_PARTNER, NETWORK_PARTNER)
82     PARTNER_TYPE_EXTRA_LABELS = (
83         _(u'Alliance'),
84         _(u'Knowledge'),
85         _(u'Network')
86     )
87 
88     PARTNER_TYPE_EXTRAS = zip(PARTNER_TYPE_EXTRAS_LIST, PARTNER_TYPE_EXTRA_LABELS)
89 
90     organisation = models.ForeignKey(
91         'Organisation', verbose_name=_(u'organisation'), related_name='partnerships', null=True,
92         blank=False, help_text=_(u'Select an organisation that is taking an active role in the '
93                                  u'project.')
94     )
95     project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='partnerships')
96     iati_organisation_role = models.PositiveSmallIntegerField(
97         u'Organisation role', choices=IATI_ROLES, db_index=True, null=True)
98     # is_secondary_reporter is only used when the iati_organisation_role is set to
99     # IATI_REPORTING_ORGANISATION, thus the use of NullBooleanField
100     is_secondary_reporter = models.NullBooleanField(
101         _(u'secondary reporter'),
102         help_text=_(
103             u'This indicates whether the reporting organisation is a secondary publisher: '
104             u'publishing data for which it is not directly responsible.'
105         )
106     )
107     funding_amount = models.DecimalField(
108         _(u'funding amount'), max_digits=14, decimal_places=2, blank=True, null=True, db_index=True,
109         help_text=_(u'The funding amount of the partner.<br>'
110                     u'Note that it\'s only possible to indicate a funding amount for funding '
111                     u'partners.')
112     )
113     partner_type_extra = ValidXMLCharField(
114         _(u'partner type extra'), max_length=30, blank=True, null=True, choices=PARTNER_TYPE_EXTRAS,
115         help_text=_(u'RSR specific partner type.')
116     )
117     iati_activity_id = ValidXMLCharField(
118         _(u'IATI activity ID'), max_length=75, blank=True, null=True, db_index=True
119     )
120     internal_id = ValidXMLCharField(
121         _(u'Internal ID'), max_length=75, blank=True, null=True, db_index=True,
122         help_text=_(u'This field can be used to indicate an internal identifier that is used by '
123                     u'the organisation for this project. (75 characters)')
124     )
125     iati_url = models.URLField(
126         blank=True,
127         help_text=_(
128             u'Please enter the URL for where the IATI Activity Id Funding details are published. '
129             u'For projects directly or indirectly funded by the Dutch Government, this should '
130             u'be the OpenAid.nl page. For other projects, an alternative URL can be used.'
131         )
132     )
133     related_activity_id = ValidXMLCharField(
134         _(u'related IATI activity ID'), max_length=50, blank=True
135     )
136 
137     def iati_organisation_role_label(self):
138         return dict(self.IATI_ROLES)[self.iati_organisation_role]
139 
140     def iati_role_to_partner_type(self):
141         if self.iati_organisation_role:
142             return self.ROLES_TO_PARTNER_TYPES_MAP[int(self.iati_organisation_role)]
143         else:
144             return None
145 
146     class Meta:
147         app_label = 'rsr'
148         verbose_name = _(u'project partner')
149         verbose_name_plural = _(u'project partners')
150         ordering = ['iati_organisation_role']
151 
152     def __unicode__(self):
153         if self.organisation:
154             if self.organisation.name:
155                 organisation_unicode = self.organisation.name
156             elif self.organisation.long_name:
157                 organisation_unicode = self.organisation.long_name
158             else:
159                 organisation_unicode = u'%s' % _(u'Organisation name not specified')
160         else:
161             organisation_unicode = u'%s' % _(u'Organisation not specified')
162 
163         if self.iati_organisation_role:
164             organisation_unicode += u' ({})'.format(
165                 unicode(dict(self.IATI_ROLES)[self.iati_organisation_role])
166             )
167         return organisation_unicode
168 
169     def clean(self):
170         # Don't allow multiple reporting organisations
171         reporting_orgs = self.project.partnerships.filter(
172             iati_organisation_role=self.IATI_REPORTING_ORGANISATION
173         )
174 
175         if reporting_orgs:
176             raise ValidationError(
177                 {'iati_organisation_role': u'%s' % _(u'Project can only have one reporting '
178                                                      u'organisation')}
179             )
180
```
--- 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/rsr/models/partnership.py b/akvo/rsr/models/partnership.py
--- a/akvo/rsr/models/partnership.py
+++ b/akvo/rsr/models/partnership.py
@@ -168,12 +168,13 @@
 
     def clean(self):
         # Don't allow multiple reporting organisations
-        reporting_orgs = self.project.partnerships.filter(
-            iati_organisation_role=self.IATI_REPORTING_ORGANISATION
-        )
-
-        if reporting_orgs:
-            raise ValidationError(
-                {'iati_organisation_role': u'%s' % _(u'Project can only have one reporting '
-                                                     u'organisation')}
+        if self.iati_organisation_role == self.IATI_REPORTING_ORGANISATION:
+            reporting_orgs = self.project.partnerships.filter(
+                iati_organisation_role=self.IATI_REPORTING_ORGANISATION
             )
+
+            if reporting_orgs.count() > 1:
+                raise ValidationError(
+                    {'iati_organisation_role': u'%s' % _(u'Project can only have one reporting '
+                                                         u'organisation')}
+                )

{"golden_diff": "diff --git a/akvo/rsr/models/partnership.py b/akvo/rsr/models/partnership.py\n--- a/akvo/rsr/models/partnership.py\n+++ b/akvo/rsr/models/partnership.py\n@@ -168,12 +168,13 @@\n \n     def clean(self):\n         # Don't allow multiple reporting organisations\n-        reporting_orgs = self.project.partnerships.filter(\n-            iati_organisation_role=self.IATI_REPORTING_ORGANISATION\n-        )\n-\n-        if reporting_orgs:\n-            raise ValidationError(\n-                {'iati_organisation_role': u'%s' % _(u'Project can only have one reporting '\n-                                                     u'organisation')}\n+        if self.iati_organisation_role == self.IATI_REPORTING_ORGANISATION:\n+            reporting_orgs = self.project.partnerships.filter(\n+                iati_organisation_role=self.IATI_REPORTING_ORGANISATION\n             )\n+\n+            if reporting_orgs.count() > 1:\n+                raise ValidationError(\n+                    {'iati_organisation_role': u'%s' % _(u'Project can only have one reporting '\n+                                                         u'organisation')}\n+                )\n", "issue": "Project can only have one reporting organisation\n## Test plan\n1. Go to project editor and select 2 reporting organisations in section 3\n2. _RESULT:_ a validation error should be shown\n3. Remove one of the reporting organisations\n4. _RESULT:_ the save should be successful\n## Issue description\n\nValidation error appears even if there's only one reporting organisation.\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\n\nfrom django.core.exceptions import ValidationError\nfrom django.db import models\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom ..fields import ValidXMLCharField\n\n\nclass Partnership(models.Model):\n    # the old way\n    FIELD_PARTNER = u'field'\n    FUNDING_PARTNER = u'funding'\n    SPONSOR_PARTNER = u'sponsor'\n    SUPPORT_PARTNER = u'support'\n    EXTENDING_PARTNER = u'extending'\n\n    PARTNER_TYPE_LIST = [\n        FIELD_PARTNER, FUNDING_PARTNER, SPONSOR_PARTNER, SUPPORT_PARTNER, EXTENDING_PARTNER\n    ]\n    PARTNER_LABELS = [\n        _(u'Implementing partner'),\n        _(u'Funding partner'),\n        _(u'Sponsor partner'),\n        _(u'Accountable partner'),\n        _(u'Extending partner'),\n    ]\n    PARTNER_TYPES = zip(PARTNER_TYPE_LIST, PARTNER_LABELS)\n\n    # the new way\n    IATI_FUNDING_PARTNER = 1\n    IATI_ACCOUNTABLE_PARTNER = 2\n    IATI_EXTENDING_PARTNER = 3\n    IATI_IMPLEMENTING_PARTNER = 4\n    AKVO_SPONSOR_PARTNER = 100   # not part of the IATI OrganisationRole codelist!\n    IATI_REPORTING_ORGANISATION = 101\n\n    # make sure the AKVO_SPONSOR_PARTNER is last in the list\n    IATI_ROLE_LIST = [\n        IATI_FUNDING_PARTNER, IATI_ACCOUNTABLE_PARTNER, IATI_EXTENDING_PARTNER,\n        IATI_IMPLEMENTING_PARTNER, AKVO_SPONSOR_PARTNER, IATI_REPORTING_ORGANISATION\n    ]\n    IATI_ROLE_LABELS = [\n        _(u'Funding partner'),\n        _(u'Accountable partner'),\n        _(u'Extending partner'),\n        _(u'Implementing partner'),\n        _(u'Sponsor partner'),\n        _(u'Reporting organisation'),\n    ]\n    IATI_ROLES = zip(IATI_ROLE_LIST, IATI_ROLE_LABELS)\n\n    # used when migrating\n    PARTNER_TYPES_TO_ROLES_MAP = {\n        FUNDING_PARTNER: IATI_FUNDING_PARTNER,\n        SUPPORT_PARTNER: IATI_ACCOUNTABLE_PARTNER,\n        FIELD_PARTNER: IATI_IMPLEMENTING_PARTNER,\n        SPONSOR_PARTNER: AKVO_SPONSOR_PARTNER,\n    }\n\n    # backwards compatibility\n    ROLES_TO_PARTNER_TYPES_MAP = {\n        IATI_FUNDING_PARTNER: FUNDING_PARTNER,\n        IATI_ACCOUNTABLE_PARTNER: SUPPORT_PARTNER,\n        IATI_EXTENDING_PARTNER: EXTENDING_PARTNER,\n        IATI_IMPLEMENTING_PARTNER: FIELD_PARTNER,\n        AKVO_SPONSOR_PARTNER: SPONSOR_PARTNER,\n        # TODO: not backwards compatible\n        IATI_REPORTING_ORGANISATION: u''\n    }\n\n    ALLIANCE_PARTNER = u'alliance'\n    KNOWLEDGE_PARTNER = u'knowledge'\n    NETWORK_PARTNER = u'network'\n\n    PARTNER_TYPE_EXTRAS_LIST = (ALLIANCE_PARTNER, KNOWLEDGE_PARTNER, NETWORK_PARTNER)\n    PARTNER_TYPE_EXTRA_LABELS = (\n        _(u'Alliance'),\n        _(u'Knowledge'),\n        _(u'Network')\n    )\n\n    PARTNER_TYPE_EXTRAS = zip(PARTNER_TYPE_EXTRAS_LIST, PARTNER_TYPE_EXTRA_LABELS)\n\n    organisation = models.ForeignKey(\n        'Organisation', verbose_name=_(u'organisation'), related_name='partnerships', null=True,\n        blank=False, help_text=_(u'Select an organisation that is taking an active role in the '\n                                 u'project.')\n    )\n    project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='partnerships')\n    iati_organisation_role = models.PositiveSmallIntegerField(\n        u'Organisation role', choices=IATI_ROLES, db_index=True, null=True)\n    # is_secondary_reporter is only used when the iati_organisation_role is set to\n    # IATI_REPORTING_ORGANISATION, thus the use of NullBooleanField\n    is_secondary_reporter = models.NullBooleanField(\n        _(u'secondary reporter'),\n        help_text=_(\n            u'This indicates whether the reporting organisation is a secondary publisher: '\n            u'publishing data for which it is not directly responsible.'\n        )\n    )\n    funding_amount = models.DecimalField(\n        _(u'funding amount'), max_digits=14, decimal_places=2, blank=True, null=True, db_index=True,\n        help_text=_(u'The funding amount of the partner.<br>'\n                    u'Note that it\\'s only possible to indicate a funding amount for funding '\n                    u'partners.')\n    )\n    partner_type_extra = ValidXMLCharField(\n        _(u'partner type extra'), max_length=30, blank=True, null=True, choices=PARTNER_TYPE_EXTRAS,\n        help_text=_(u'RSR specific partner type.')\n    )\n    iati_activity_id = ValidXMLCharField(\n        _(u'IATI activity ID'), max_length=75, blank=True, null=True, db_index=True\n    )\n    internal_id = ValidXMLCharField(\n        _(u'Internal ID'), max_length=75, blank=True, null=True, db_index=True,\n        help_text=_(u'This field can be used to indicate an internal identifier that is used by '\n                    u'the organisation for this project. (75 characters)')\n    )\n    iati_url = models.URLField(\n        blank=True,\n        help_text=_(\n            u'Please enter the URL for where the IATI Activity Id Funding details are published. '\n            u'For projects directly or indirectly funded by the Dutch Government, this should '\n            u'be the OpenAid.nl page. For other projects, an alternative URL can be used.'\n        )\n    )\n    related_activity_id = ValidXMLCharField(\n        _(u'related IATI activity ID'), max_length=50, blank=True\n    )\n\n    def iati_organisation_role_label(self):\n        return dict(self.IATI_ROLES)[self.iati_organisation_role]\n\n    def iati_role_to_partner_type(self):\n        if self.iati_organisation_role:\n            return self.ROLES_TO_PARTNER_TYPES_MAP[int(self.iati_organisation_role)]\n        else:\n            return None\n\n    class Meta:\n        app_label = 'rsr'\n        verbose_name = _(u'project partner')\n        verbose_name_plural = _(u'project partners')\n        ordering = ['iati_organisation_role']\n\n    def __unicode__(self):\n        if self.organisation:\n            if self.organisation.name:\n                organisation_unicode = self.organisation.name\n            elif self.organisation.long_name:\n                organisation_unicode = self.organisation.long_name\n            else:\n                organisation_unicode = u'%s' % _(u'Organisation name not specified')\n        else:\n            organisation_unicode = u'%s' % _(u'Organisation not specified')\n\n        if self.iati_organisation_role:\n            organisation_unicode += u' ({})'.format(\n                unicode(dict(self.IATI_ROLES)[self.iati_organisation_role])\n            )\n        return organisation_unicode\n\n    def clean(self):\n        # Don't allow multiple reporting organisations\n        reporting_orgs = self.project.partnerships.filter(\n            iati_organisation_role=self.IATI_REPORTING_ORGANISATION\n        )\n\n        if reporting_orgs:\n            raise ValidationError(\n                {'iati_organisation_role': u'%s' % _(u'Project can only have one reporting '\n                                                     u'organisation')}\n            )\n", "path": "akvo/rsr/models/partnership.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\n\nfrom django.core.exceptions import ValidationError\nfrom django.db import models\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom ..fields import ValidXMLCharField\n\n\nclass Partnership(models.Model):\n    # the old way\n    FIELD_PARTNER = u'field'\n    FUNDING_PARTNER = u'funding'\n    SPONSOR_PARTNER = u'sponsor'\n    SUPPORT_PARTNER = u'support'\n    EXTENDING_PARTNER = u'extending'\n\n    PARTNER_TYPE_LIST = [\n        FIELD_PARTNER, FUNDING_PARTNER, SPONSOR_PARTNER, SUPPORT_PARTNER, EXTENDING_PARTNER\n    ]\n    PARTNER_LABELS = [\n        _(u'Implementing partner'),\n        _(u'Funding partner'),\n        _(u'Sponsor partner'),\n        _(u'Accountable partner'),\n        _(u'Extending partner'),\n    ]\n    PARTNER_TYPES = zip(PARTNER_TYPE_LIST, PARTNER_LABELS)\n\n    # the new way\n    IATI_FUNDING_PARTNER = 1\n    IATI_ACCOUNTABLE_PARTNER = 2\n    IATI_EXTENDING_PARTNER = 3\n    IATI_IMPLEMENTING_PARTNER = 4\n    AKVO_SPONSOR_PARTNER = 100   # not part of the IATI OrganisationRole codelist!\n    IATI_REPORTING_ORGANISATION = 101\n\n    # make sure the AKVO_SPONSOR_PARTNER is last in the list\n    IATI_ROLE_LIST = [\n        IATI_FUNDING_PARTNER, IATI_ACCOUNTABLE_PARTNER, IATI_EXTENDING_PARTNER,\n        IATI_IMPLEMENTING_PARTNER, AKVO_SPONSOR_PARTNER, IATI_REPORTING_ORGANISATION\n    ]\n    IATI_ROLE_LABELS = [\n        _(u'Funding partner'),\n        _(u'Accountable partner'),\n        _(u'Extending partner'),\n        _(u'Implementing partner'),\n        _(u'Sponsor partner'),\n        _(u'Reporting organisation'),\n    ]\n    IATI_ROLES = zip(IATI_ROLE_LIST, IATI_ROLE_LABELS)\n\n    # used when migrating\n    PARTNER_TYPES_TO_ROLES_MAP = {\n        FUNDING_PARTNER: IATI_FUNDING_PARTNER,\n        SUPPORT_PARTNER: IATI_ACCOUNTABLE_PARTNER,\n        FIELD_PARTNER: IATI_IMPLEMENTING_PARTNER,\n        SPONSOR_PARTNER: AKVO_SPONSOR_PARTNER,\n    }\n\n    # backwards compatibility\n    ROLES_TO_PARTNER_TYPES_MAP = {\n        IATI_FUNDING_PARTNER: FUNDING_PARTNER,\n        IATI_ACCOUNTABLE_PARTNER: SUPPORT_PARTNER,\n        IATI_EXTENDING_PARTNER: EXTENDING_PARTNER,\n        IATI_IMPLEMENTING_PARTNER: FIELD_PARTNER,\n        AKVO_SPONSOR_PARTNER: SPONSOR_PARTNER,\n        # TODO: not backwards compatible\n        IATI_REPORTING_ORGANISATION: u''\n    }\n\n    ALLIANCE_PARTNER = u'alliance'\n    KNOWLEDGE_PARTNER = u'knowledge'\n    NETWORK_PARTNER = u'network'\n\n    PARTNER_TYPE_EXTRAS_LIST = (ALLIANCE_PARTNER, KNOWLEDGE_PARTNER, NETWORK_PARTNER)\n    PARTNER_TYPE_EXTRA_LABELS = (\n        _(u'Alliance'),\n        _(u'Knowledge'),\n        _(u'Network')\n    )\n\n    PARTNER_TYPE_EXTRAS = zip(PARTNER_TYPE_EXTRAS_LIST, PARTNER_TYPE_EXTRA_LABELS)\n\n    organisation = models.ForeignKey(\n        'Organisation', verbose_name=_(u'organisation'), related_name='partnerships', null=True,\n        blank=False, help_text=_(u'Select an organisation that is taking an active role in the '\n                                 u'project.')\n    )\n    project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='partnerships')\n    iati_organisation_role = models.PositiveSmallIntegerField(\n        u'Organisation role', choices=IATI_ROLES, db_index=True, null=True)\n    # is_secondary_reporter is only used when the iati_organisation_role is set to\n    # IATI_REPORTING_ORGANISATION, thus the use of NullBooleanField\n    is_secondary_reporter = models.NullBooleanField(\n        _(u'secondary reporter'),\n        help_text=_(\n            u'This indicates whether the reporting organisation is a secondary publisher: '\n            u'publishing data for which it is not directly responsible.'\n        )\n    )\n    funding_amount = models.DecimalField(\n        _(u'funding amount'), max_digits=14, decimal_places=2, blank=True, null=True, db_index=True,\n        help_text=_(u'The funding amount of the partner.<br>'\n                    u'Note that it\\'s only possible to indicate a funding amount for funding '\n                    u'partners.')\n    )\n    partner_type_extra = ValidXMLCharField(\n        _(u'partner type extra'), max_length=30, blank=True, null=True, choices=PARTNER_TYPE_EXTRAS,\n        help_text=_(u'RSR specific partner type.')\n    )\n    iati_activity_id = ValidXMLCharField(\n        _(u'IATI activity ID'), max_length=75, blank=True, null=True, db_index=True\n    )\n    internal_id = ValidXMLCharField(\n        _(u'Internal ID'), max_length=75, blank=True, null=True, db_index=True,\n        help_text=_(u'This field can be used to indicate an internal identifier that is used by '\n                    u'the organisation for this project. (75 characters)')\n    )\n    iati_url = models.URLField(\n        blank=True,\n        help_text=_(\n            u'Please enter the URL for where the IATI Activity Id Funding details are published. '\n            u'For projects directly or indirectly funded by the Dutch Government, this should '\n            u'be the OpenAid.nl page. For other projects, an alternative URL can be used.'\n        )\n    )\n    related_activity_id = ValidXMLCharField(\n        _(u'related IATI activity ID'), max_length=50, blank=True\n    )\n\n    def iati_organisation_role_label(self):\n        return dict(self.IATI_ROLES)[self.iati_organisation_role]\n\n    def iati_role_to_partner_type(self):\n        if self.iati_organisation_role:\n            return self.ROLES_TO_PARTNER_TYPES_MAP[int(self.iati_organisation_role)]\n        else:\n            return None\n\n    class Meta:\n        app_label = 'rsr'\n        verbose_name = _(u'project partner')\n        verbose_name_plural = _(u'project partners')\n        ordering = ['iati_organisation_role']\n\n    def __unicode__(self):\n        if self.organisation:\n            if self.organisation.name:\n                organisation_unicode = self.organisation.name\n            elif self.organisation.long_name:\n                organisation_unicode = self.organisation.long_name\n            else:\n                organisation_unicode = u'%s' % _(u'Organisation name not specified')\n        else:\n            organisation_unicode = u'%s' % _(u'Organisation not specified')\n\n        if self.iati_organisation_role:\n            organisation_unicode += u' ({})'.format(\n                unicode(dict(self.IATI_ROLES)[self.iati_organisation_role])\n            )\n        return organisation_unicode\n\n    def clean(self):\n        # Don't allow multiple reporting organisations\n        if self.iati_organisation_role == self.IATI_REPORTING_ORGANISATION:\n            reporting_orgs = self.project.partnerships.filter(\n                iati_organisation_role=self.IATI_REPORTING_ORGANISATION\n            )\n\n            if reporting_orgs.count() > 1:\n                raise ValidationError(\n                    {'iati_organisation_role': u'%s' % _(u'Project can only have one reporting '\n                                                         u'organisation')}\n                )\n", "path": "akvo/rsr/models/partnership.py"}]}