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

b/snf-astakos-app/astakos/im/models.py
1283 1283

  
1284 1284

  
1285 1285
class ProjectApplicationManager(ForUpdateManager):
1286
    pass
1286

  
1287
    def pending_per_project(self, projects):
1288
        apps = self.filter(state=self.model.PENDING,
1289
                           chain__in=projects).order_by('chain', '-id')
1290
        checked_chain = None
1291
        projs = {}
1292
        for app in apps:
1293
            chain = app.chain_id
1294
            if chain != checked_chain:
1295
                checked_chain = chain
1296
                projs[chain] = app
1297
        return projs
1287 1298

  
1288 1299

  
1289 1300
class ProjectApplication(models.Model):
......
1666 1677
            return None
1667 1678
        return last_pending
1668 1679

  
1669
    def has_pending_modifications(self):
1670
        last_pending = self.last_pending_modification()
1671
        return last_pending is not None
1672

  
1673 1680
    def state_display(self):
1674 1681
        return self.O_STATE_DISPLAY.get(self.overall_state(), _('Unknown'))
1675 1682

  
......
1806 1813
    def associated(self):
1807 1814
        return self.filter(state__in=ProjectMembership.ASSOCIATED_STATES)
1808 1815

  
1816
    def any_accepted_per_project(self, projects):
1817
        ms = self.any_accepted().filter(project__in=projects)
1818
        return _partition_by(lambda m: m.project_id, ms)
1819

  
1820
    def requested_per_project(self, projects):
1821
        ms = self.requested().filter(project__in=projects)
1822
        return _partition_by(lambda m: m.project_id, ms)
1823

  
1824
    def one_per_project(self):
1825
        ms = self.all().select_related(
1826
            'project', 'project__application',
1827
            'project__application__owner', 'project_application__applicant',
1828
            'person')
1829
        m_per_p = {}
1830
        for m in ms:
1831
            m_per_p[m.project_id] = m
1832
        return m_per_p
1833

  
1809 1834

  
1810 1835
class ProjectMembership(models.Model):
1811 1836

  

Also available in: Unified diff