← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wallyworld/launchpad/admins-can-unsubscribe-bugs into lp:launchpad

 

Ian Booth has proposed merging lp:~wallyworld/launchpad/admins-can-unsubscribe-bugs into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #633 in Launchpad itself: "cannot undo accidental subscription of a third party to a bug"
  https://bugs.launchpad.net/launchpad/+bug/633
  Bug #134577 in Launchpad itself: "Admins should be able to unsubscribe other people from bug reports"
  https://bugs.launchpad.net/launchpad/+bug/134577

For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/admins-can-unsubscribe-bugs/+merge/65615

Simple fix to extend who can ubsubscribe someone from a bug.
As well as oneself, one can be unsubscribed from a bug by:
- lp admins
- the person who subscribed you

== Implementation ==

Add to the BugSubscription.canBeUnsubscribedByUser() method

== Tests ==

Add some lines to the bugsubscription.txt doc test to check that the two new unsubscriber users are allowed.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/doc/bugsubscription.txt
  lib/lp/bugs/model/bugsubscription.py


-- 
https://code.launchpad.net/~wallyworld/launchpad/admins-can-unsubscribe-bugs/+merge/65615
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wallyworld/launchpad/admins-can-unsubscribe-bugs into lp:launchpad.
=== modified file 'lib/lp/bugs/doc/bugsubscription.txt'
--- lib/lp/bugs/doc/bugsubscription.txt	2011-06-07 06:24:04 +0000
+++ lib/lp/bugs/doc/bugsubscription.txt	2011-06-23 04:08:32 +0000
@@ -621,11 +621,18 @@
     >>> subscription.canBeUnsubscribedByUser(subscriber)
     True
 
-The one who subscribed the subscriber doesn't have permission to
+The one who subscribed the subscriber does have permission to
 unsubscribe him.
 
     >>> subscription.canBeUnsubscribedByUser(subscribed_by)
-    False
+    True
+
+So too can Launchpad administrators unsubscribe him.
+
+    >>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
+    >>> subscription.canBeUnsubscribedByUser(
+    ...     getUtility(ILaunchpadCelebrities).admin)
+    True
 
 The anonymous user (represented by None) also can't unsubscribe him.
 

=== modified file 'lib/lp/bugs/model/bugsubscription.py'
--- lib/lp/bugs/model/bugsubscription.py	2011-02-01 04:57:42 +0000
+++ lib/lp/bugs/model/bugsubscription.py	2011-06-23 04:08:32 +0000
@@ -12,10 +12,12 @@
     Int,
     Reference,
     )
+from zope.component import getUtility
 from zope.interface import implements
 
 from canonical.database.constants import UTC_NOW
 from canonical.database.enumcol import DBEnum
+from lp.app.interfaces.launchpad import ILaunchpadCelebrities
 from lp.bugs.enum import BugNotificationLevel
 from lp.bugs.interfaces.bugsubscription import IBugSubscription
 from lp.registry.interfaces.person import validate_person
@@ -79,6 +81,11 @@
         """See `IBugSubscription`."""
         if user is None:
             return False
+        celebrities = getUtility(ILaunchpadCelebrities)
+        if user.inTeam(celebrities.admin):
+            return True
+        if user == self.subscribed_by:
+            return True
         if self.person.is_team:
             return user.inTeam(self.person)
         return user == self.person


Follow ups