← 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:57:29 +0000
@@ -621,11 +621,16 @@
     >>> 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.
+
+    >>> subscription.canBeUnsubscribedByUser(foobar)
+    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:57:29 +0000
@@ -19,6 +19,7 @@
 from lp.bugs.enum import BugNotificationLevel
 from lp.bugs.interfaces.bugsubscription import IBugSubscription
 from lp.registry.interfaces.person import validate_person
+from lp.registry.interfaces.role import IPersonRoles
 from lp.services.database.stormbase import StormBase
 
 
@@ -79,6 +80,6 @@
         """See `IBugSubscription`."""
         if user is None:
             return False
-        if self.person.is_team:
-            return user.inTeam(self.person)
-        return user == self.person
+        return (user.inTeam(self.person) or
+                user.inTeam(self.subscribed_by) or
+                IPersonRoles(user).in_admin)