'Make sure there is only one poc and author per resource'

def clean(self):

    if ((self.role == self.resource.poc_role) or (self.role == self.resource.metadata_author_role)):
        contacts = self.resource.contacts.filter(contactrole__role=self.role)
        if (contacts.count() == 1):
            if (self.contact != contacts.get()):
                raise ValidationError(('There    can    be    only    one    %s    for    a    given    resource' % self.role))
    if (self.contact.user is None):
        bounds = ContactRole.objects.filter(contact=self.contact).count()
        if (bounds > 1):
            raise ValidationError(('There    can    be    one    and    only    one    resource    linked    to    an    unbound    contact' % self.role))
        elif (bounds == 1):
            if (ContactRole.objects.filter(contact=self.contact).get().id != self.id):
                raise ValidationError(('There    can    be    one    and    only    one    resource    linked    to    an    unbound    contact' % self.role))
