← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wallyworld/launchpad/leave-private-team-404-982648 into lp:launchpad

 

Ian Booth has proposed merging lp:~wallyworld/launchpad/leave-private-team-404-982648 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #982648 in Launchpad itself: "404 after leaving private team"
  https://bugs.launchpad.net/launchpad/+bug/982648

For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/leave-private-team-404-982648/+merge/102667

== Implementation ==

Change how next_url is set on the TeamLeaveView. Redirect user to their homepage when they leave a private team. Also add an informational message.

== Tests ==

Update xx-team-leave.txt doc test.

== Lint ==

Replaced some tabs with spaces.

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/browser/team.py
  lib/lp/registry/stories/teammembership/xx-team-leave.txt

./lib/lp/registry/stories/teammembership/xx-team-leave.txt
       1: narrative uses a moin header.
      27: narrative uses a moin header.
      52: narrative uses a moin header.
-- 
https://code.launchpad.net/~wallyworld/launchpad/leave-private-team-404-982648/+merge/102667
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wallyworld/launchpad/leave-private-team-404-982648 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/team.py'
--- lib/lp/registry/browser/team.py	2012-04-05 13:45:31 +0000
+++ lib/lp/registry/browser/team.py	2012-04-19 10:56:19 +0000
@@ -1995,6 +1995,10 @@
 class TeamLeaveView(LaunchpadFormView, TeamJoinMixin):
     schema = Interface
 
+    def __init__(self, context, request):
+        super(TeamLeaveView, self).__init__(context, request)
+        self._next_url = self.cancel_url
+
     @property
     def label(self):
         return 'Leave ' + cgi.escape(self.context.displayname)
@@ -2005,12 +2009,20 @@
     def cancel_url(self):
         return canonical_url(self.context)
 
-    next_url = cancel_url
+    @property
+    def next_url(self):
+        return  self._next_url
 
     @action(_("Leave"), name="leave")
     def action_save(self, action, data):
         if self.user_can_request_to_leave:
             self.user.leave(self.context)
+            if self.context.visibility == PersonVisibility.PRIVATE:
+                self.request.response.addNotification(
+                    "You are no longer a member of private team %s "
+                    "and are not authorised to view the team."
+                        % self.context.displayname)
+                self._next_url = canonical_url(self.user)
 
 
 class TeamReassignmentView(ObjectReassignmentView):

=== modified file 'lib/lp/registry/stories/teammembership/xx-team-leave.txt'
--- lib/lp/registry/stories/teammembership/xx-team-leave.txt	2009-09-18 15:24:30 +0000
+++ lib/lp/registry/stories/teammembership/xx-team-leave.txt	2012-04-19 10:56:19 +0000
@@ -24,6 +24,31 @@
     'http://launchpad.dev/~ubuntu-team/+join'
 
 
+== Leaving a private team ==
+
+When someone leaves a private team, they are no longer able to see the team so
+are redirected to their personal Launchpad homepage with a suitable message.
+
+    >>> browser = setupBrowser(auth='Basic member@xxxxxxxxxxxxx:test')
+    >>> browser.open('http://launchpad.dev/~myteam')
+    >>> browser.title
+    'My Team in Launchpad'
+
+    >>> browser.getLink('Leave').click()
+    >>> browser.title
+    'Leave My Team...
+
+    >>> browser.getControl('Leave').click()
+
+User is redirect to their homepage page after leaving.
+
+    >>> browser.url
+    'http://launchpad.dev/~member'
+
+    >>> print extract_text(
+    ...     first_tag_by_class(browser.contents, 'informational message'))
+    You are no longer a member of private team...
+
 == Team overview page quick-links ==
 
 A member of a team can quickly leave a team by using the links on the
@@ -32,7 +57,7 @@
     >>> browser = setupBrowser(auth='Basic carlos@xxxxxxxxxxxxx:test')
     >>> browser.open('http://launchpad.dev/~admins')
     >>> print extract_text(
-    ... 	find_tag_by_id(browser.contents, 'your-involvement'))
+    ...     find_tag_by_id(browser.contents, 'your-involvement'))
     You are a member of this team...
     >>> browser.getLink('Leave the Team').click()
     >>> browser.title
@@ -55,7 +80,7 @@
 
     >>> browser.open('http://launchpad.dev/~testing-spanish-team')
     >>> print extract_text(
-    ... 	find_tag_by_id(browser.contents, 'your-involvement'))
+    ...     find_tag_by_id(browser.contents, 'your-involvement'))
     You are the owner of this team...
     >>> browser.getLink('Leave the Team')
     Traceback (most recent call last):