~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/model/bug.py

[r=sinzui][bug=253068] Allow rejected bug nominations to be
 renominated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
    )
151
151
from lp.bugs.interfaces.bugmessage import IBugMessageSet
152
152
from lp.bugs.interfaces.bugnomination import (
 
153
    BugNominationStatus,
153
154
    NominationError,
154
155
    NominationSeriesObsoleteError,
155
156
    )
1550
1551
            raise NominationError(
1551
1552
                "Only bug supervisors or owners can nominate bugs.")
1552
1553
 
1553
 
        nomination = BugNomination(
1554
 
            owner=owner, bug=self, distroseries=distroseries,
1555
 
            productseries=productseries)
 
1554
        # There may be an existing DECLINED nomination. If so, we set the
 
1555
        # status back to PROPOSED. We do not alter the original date_created.
 
1556
        nomination = None
 
1557
        try:
 
1558
            nomination = self.getNominationFor(target)
 
1559
        except NotFoundError:
 
1560
            pass
 
1561
        if nomination:
 
1562
            nomination.status = BugNominationStatus.PROPOSED
 
1563
            nomination.decider = None
 
1564
            nomination.date_decided = None
 
1565
        else:
 
1566
            nomination = BugNomination(
 
1567
                owner=owner, bug=self, distroseries=distroseries,
 
1568
                productseries=productseries)
1556
1569
        self.addChange(SeriesNominated(UTC_NOW, owner, target))
1557
1570
        return nomination
1558
1571
 
1559
1572
    def canBeNominatedFor(self, target):
1560
1573
        """See `IBug`."""
1561
1574
        try:
1562
 
            self.getNominationFor(target)
 
1575
            nomination = self.getNominationFor(target)
1563
1576
        except NotFoundError:
1564
1577
            # No nomination exists. Let's see if the bug is already
1565
1578
            # directly targeted to this nomination target.
1589
1602
            # No tasks match the candidate's pillar. We must refuse.
1590
1603
            return False
1591
1604
        else:
1592
 
            # The bug is already nominated for this nomination target.
 
1605
            # The bug may be already nominated for this nomination target.
 
1606
            # If the status is declined, the bug can be renominated, else
 
1607
            # return False
 
1608
            if nomination:
 
1609
                return nomination.status == BugNominationStatus.DECLINED
1593
1610
            return False
1594
1611
 
1595
1612
    def getNominationFor(self, target):