Revision efc58b65 snf-astakos-app/astakos/im/models.py

b/snf-astakos-app/astakos/im/models.py
1297 1297
            return
1298 1298

  
1299 1299
    def followers(self):
1300
        followers = ProjectApplication.objects.filter(chain=self.chain)
1301
        return followers.exclude(pk=self.pk).order_by('id')
1300
        followers = self.chained_applications()
1301
        followers = followers.exclude(id=self.pk).filter(state=self.PENDING)
1302
        followers = followers.order_by('id')
1303
        return followers
1302 1304

  
1303 1305
    def last_follower(self):
1304 1306
        try:
1305
            return self.followers().filter(
1306
                          state__in=[self.PENDING, self.APPROVED]).order_by('-id')[0]
1307
            return self.followers().order_by('-id')[0]
1307 1308
        except IndexError:
1308 1309
            return None
1309 1310

  
1311
    def is_modification(self):
1312
        parents = self.chained_applications().filter(id__lt=self.id)
1313
        parents = parents.filter(state__in=[self.APPROVED])
1314
        return parents.count() > 0
1315

  
1316
    def chained_applications(self):
1317
        return ProjectApplication.objects.filter(chain=self.chain)
1318

  
1310 1319
    def has_pending_modifications(self):
1311 1320
        return bool(self.last_follower())
1312 1321

  

Also available in: Unified diff