~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/person.py

  • Committer: Stuart Bishop
  • Date: 2011-09-28 12:49:24 UTC
  • mfrom: (9893.10.1 trivial)
  • mto: This revision was merged to the branch mainline in revision 14178.
  • Revision ID: stuart.bishop@canonical.com-20110928124924-m5a22fymqghw6c5i
Merged trivial into distinct-db-users.

Show diffs side-by-side

added added

removed removed

Lines of Context:
297
297
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
298
298
from lp.soyuz.interfaces.archivesubscriber import IArchiveSubscriberSet
299
299
from lp.soyuz.model.archive import Archive
 
300
from lp.soyuz.model.publishing import SourcePackagePublishingHistory
300
301
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
301
302
from lp.translations.model.hastranslationimports import (
302
303
    HasTranslationImportsMixin,
2586
2587
        """See `IPerson`."""
2587
2588
        return self._latestSeriesQuery()
2588
2589
 
 
2590
    def getLatestSynchronisedPublishings(self):
 
2591
        """See `IPerson`."""
 
2592
        query = """
 
2593
            SourcePackagePublishingHistory.id IN (
 
2594
                SELECT DISTINCT ON (spph.distroseries,
 
2595
                                    spr.sourcepackagename)
 
2596
                    spph.id
 
2597
                FROM
 
2598
                    SourcePackagePublishingHistory as spph, archive,
 
2599
                    SourcePackagePublishingHistory as ancestor_spph,
 
2600
                    SourcePackageRelease as spr
 
2601
                WHERE
 
2602
                    spph.sourcepackagerelease = spr.id AND
 
2603
                    spph.creator = %(creator)s AND
 
2604
                    spph.ancestor = ancestor_spph.id AND
 
2605
                    spph.archive = archive.id AND
 
2606
                    ancestor_spph.archive != spph.archive AND
 
2607
                    archive.purpose = %(archive_purpose)s
 
2608
                ORDER BY spph.distroseries,
 
2609
                    spr.sourcepackagename,
 
2610
                    spph.datecreated DESC,
 
2611
                    spph.id DESC
 
2612
            )
 
2613
            """ % dict(
 
2614
                   creator=quote(self.id),
 
2615
                   archive_purpose=quote(ArchivePurpose.PRIMARY),
 
2616
                   )
 
2617
 
 
2618
        return SourcePackagePublishingHistory.select(
 
2619
            query,
 
2620
            orderBy=['-SourcePackagePublishingHistory.datecreated',
 
2621
                     '-SourcePackagePublishingHistory.id'],
 
2622
            prejoins=['sourcepackagerelease', 'archive'])
 
2623
 
2589
2624
    def getLatestUploadedButNotMaintainedPackages(self):
2590
2625
        """See `IPerson`."""
2591
2626
        return self._latestSeriesQuery(uploader_only=True)
4639
4674
    If <person> has a preferred email, the set will contain only that
4640
4675
    person.  If <person> doesn't have a preferred email but is a team,
4641
4676
    the set will contain the preferred email address of each member of
4642
 
    <person>, including indirect members.
 
4677
    <person>, including indirect members, that has an active account and an
 
4678
    preferred (active) address.
4643
4679
 
4644
4680
    Finally, if <person> doesn't have a preferred email and is not a team,
4645
4681
    the set will be empty.
4647
4683
    if person.preferredemail:
4648
4684
        return [person]
4649
4685
    elif person.is_team:
4650
 
        # Get transitive members of team without a preferred email.
 
4686
        # Get transitive members of a team that does not itself have a
 
4687
        # preferred email.
4651
4688
        return _get_recipients_for_team(person)
4652
4689
    else:
4653
4690
        return []
4666
4703
                                  And(
4667
4704
                                      EmailAddress.person == Person.id,
4668
4705
                                      EmailAddress.status ==
4669
 
                                        EmailAddressStatus.PREFERRED)))
 
4706
                                        EmailAddressStatus.PREFERRED)),
 
4707
                         LeftJoin(Account,
 
4708
                             Person.accountID == Account.id))
4670
4709
    pending_team_ids = [team.id]
4671
4710
    recipient_ids = set()
4672
4711
    seen = set()
4673
4712
    while pending_team_ids:
4674
 
        # Find Persons that have a preferred email address, or are a
4675
 
        # team, or both.
 
4713
        # Find Persons that have a preferred email address and an active
 
4714
        # account, or are a team, or both.
4676
4715
        intermediate_transitive_results = source.find(
4677
4716
            (TeamMembership.personID, EmailAddress.personID),
4678
4717
            In(TeamMembership.status,
4680
4719
                TeamMembershipStatus.APPROVED.value]),
4681
4720
            In(TeamMembership.teamID, pending_team_ids),
4682
4721
            Or(
4683
 
                EmailAddress.personID != None,
 
4722
                And(EmailAddress.personID != None,
 
4723
                    Account.status == AccountStatus.ACTIVE),
4684
4724
                Person.teamownerID != None)).config(distinct=True)
4685
4725
        next_ids = []
4686
4726
        for (person_id,