Skip to content

Commit

Permalink
[#1874] Fix reporting org validation
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Oct 25, 2015
1 parent 48ce7d4 commit 2dd10ea
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions akvo/rsr/models/partnership.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ def __unicode__(self):

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')}
)

0 comments on commit 2dd10ea

Please sign in to comment.