Remove submitter field from professional services
authorMagnus Hagander <magnus@hagander.net>
Sun, 27 Nov 2011 16:49:12 +0000 (17:49 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sun, 27 Nov 2011 16:50:40 +0000 (17:50 +0100)
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

pgweb/profserv/models.py

index f0a779aa3ed4b27fbe538856a5295a403c6c5415..feebe29a5da330e305edd5c4cba099781569bc83 100644 (file)
@@ -5,7 +5,6 @@ from pgweb.core.models import Organisation
 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)
@@ -32,6 +31,9 @@ class ProfessionalService(PgModel, models.Model):
        
        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