The rest of the code already dealt with profservs attached to organisations,
but the existance of tihs field causded the validation to reject any
updates since this field is wrong. Instead, create a verify_submitter()
function that checks the permissions on the organisation.
This fixes #98
from pgweb.util.bases import PgModel
class ProfessionalService(PgModel, models.Model):
- submitter = models.ForeignKey(User, null=False, blank=False)
approved = models.BooleanField(null=False, blank=False, default=False)
organisation = models.ForeignKey(Organisation, null=False, blank=False, unique=True)
send_notification = True
+ def verify_submitter(self, user):
+ return (len(self.organisation.managers.filter(pk=user.pk)) == 1)
+
def __unicode__(self):
return self.organisation.name