← Back to team overview

launchpad-reviewers team mailing list archive

lp:~wallyworld/launchpad/cannot-renominate-bugtask-after-deletion-904902 into lp:launchpad

 

Ian Booth has proposed merging lp:~wallyworld/launchpad/cannot-renominate-bugtask-after-deletion-904902 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #904902 in Launchpad itself: "can't renominate to a series after the series bugtask was deleted"
  https://bugs.launchpad.net/launchpad/+bug/904902

For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/cannot-renominate-bugtask-after-deletion-904902/+merge/86158

When a bugtask is deleted, also delete any associated BugNomination record so that the bug can then be re-nominated against the target again.

== Implementation ==

Update Postgres security.cfg to allow BugNominations to be deleted.
When a bug tasks is deleted, delete any associated bug nomination.

== QA ==

Delete a bugtask associated with a product or distro series. Then check that +nominate allows the bug to be nominated against the target series for which the bugtask was deleted.

== Tests ==

Add a check to TestBugTaskDeletion.test_delete_bugtask so ensure that bug.canBeNominatedFor(target) returns true.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  database/schema/security.cfg
  lib/lp/bugs/configure.zcml
  lib/lp/bugs/model/bugtask.py
  lib/lp/bugs/model/tests/test_bugtask.py
-- 
https://code.launchpad.net/~wallyworld/launchpad/cannot-renominate-bugtask-after-deletion-904902/+merge/86158
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wallyworld/launchpad/cannot-renominate-bugtask-after-deletion-904902 into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2011-12-14 20:03:40 +0000
+++ database/schema/security.cfg	2011-12-18 08:20:31 +0000
@@ -1115,7 +1115,7 @@
 public.bugjob                           = SELECT, INSERT
 public.bugmessage                       = SELECT, INSERT, UPDATE
 public.bugmute                          = SELECT, INSERT, UPDATE, DELETE
-public.bugnomination                    = SELECT, INSERT, UPDATE
+public.bugnomination                    = SELECT, INSERT, UPDATE, DELETE
 public.bugsubscription                  = SELECT, INSERT, UPDATE, DELETE
 public.bugsubscriptionfilter            = SELECT, INSERT, UPDATE, DELETE
 public.bugsubscriptionfilterimportance  = SELECT, INSERT, UPDATE, DELETE

=== modified file 'lib/lp/bugs/configure.zcml'
--- lib/lp/bugs/configure.zcml	2011-12-12 14:47:38 +0000
+++ lib/lp/bugs/configure.zcml	2011-12-18 08:20:31 +0000
@@ -952,6 +952,10 @@
                 attributes="
                     approve
                     decline"/>
+            <require
+                permission="launchpad.Edit"
+                attributes="
+                    destroySelf"/>
         </class>
         <securedutility
             class="lp.bugs.model.bugnomination.BugNominationSet"

=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py	2011-12-14 12:30:53 +0000
+++ lib/lp/bugs/model/bugtask.py	2011-12-18 08:20:31 +0000
@@ -683,6 +683,17 @@
         self.destroySelf()
         del get_property_cache(bug).bugtasks
 
+        # When a task is deleted, we also delete it's BugNomination entry
+        # if there is one. Sadly, getNominationFor() can return None or
+        # raise NotFoundError so we need to check for both.
+        try:
+            nomination = bug.getNominationFor(target)
+            if nomination is not None:
+                nomination.destroySelf()
+        except NotFoundError:
+            # We don't care if there isn't a nomination
+            pass
+
         # When a task is deleted the bug's heat needs to be recalculated.
         target.recalculateBugHeatCache()
 

=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
--- lib/lp/bugs/model/tests/test_bugtask.py	2011-12-12 01:08:21 +0000
+++ lib/lp/bugs/model/tests/test_bugtask.py	2011-12-18 08:20:31 +0000
@@ -1553,13 +1553,17 @@
 
     def test_delete_bugtask(self):
         # A bugtask can be deleted.
-        bug = self.factory.makeBug()
-        bugtask = self.factory.makeBugTask(bug=bug)
+        product = self.factory.makeProduct()
+        bug = self.factory.makeBug(product=product)
+        target = self.factory.makeProductSeries(product=product)
+        bugtask = self.factory.makeBugTask(bug=bug, target=target)
         bug = bugtask.bug
+        self.factory.makeBugNomination(bug=bug, target=target)
         login_person(bugtask.owner)
         with FeatureFixture(self.flags):
             bugtask.delete()
         self.assertEqual([bug.default_bugtask], bug.bugtasks)
+        self.assertTrue(bug.canBeNominatedFor(target))
 
     def test_delete_default_bugtask(self):
         # The default bugtask can be deleted.