~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/team.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-14 18:16:47 UTC
  • mfrom: (14515 devel)
  • mto: This revision was merged to the branch mainline in revision 14593.
  • Revision ID: launchpad@pqm.canonical.com-20111214181647-jh80eps1ndcy6hns
[rs=buildbot-poller] automatic merge from stable. Revisions: 14510,
        14511, 14512, 14513, 14514, 14515 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
    NavigationMenu,
84
84
    stepthrough,
85
85
    )
86
 
from canonical.launchpad.webapp.authorization import check_permission
 
86
from canonical.launchpad.webapp.authorization import (
 
87
    check_permission,
 
88
    clear_cache,
 
89
    )
87
90
from canonical.launchpad.webapp.batching import (
88
91
    ActiveBatchNavigator,
89
92
    InactiveBatchNavigator,
2052
2055
 
2053
2056
    def __init__(self, context, request):
2054
2057
        super(TeamReassignmentView, self).__init__(context, request)
2055
 
        self.callback = self._addOwnerAsMember
 
2058
        self.callback = self._afterOwnerChange
 
2059
        self.teamdisplayname = self.contextName
 
2060
        self._next_url = canonical_url(self.context)
2056
2061
 
2057
2062
    def validateOwner(self, new_owner):
2058
2063
        """Display error if the owner is not valid.
2084
2089
    def contextName(self):
2085
2090
        return self.context.displayname
2086
2091
 
2087
 
    def _addOwnerAsMember(self, team, oldOwner, newOwner):
 
2092
    @property
 
2093
    def next_url(self):
 
2094
        return self._next_url
 
2095
 
 
2096
    def _afterOwnerChange(self, team, oldOwner, newOwner):
2088
2097
        """Add the new and the old owners as administrators of the team.
2089
2098
 
2090
2099
        When a user creates a new team, he is added as an administrator of
2105
2114
                oldOwner, reviewer=oldOwner,
2106
2115
                status=TeamMembershipStatus.ADMIN, force_team_add=True)
2107
2116
 
 
2117
        # If the current logged in user cannot see the team anymore as a
 
2118
        # result of the ownership change, we don't want them to get a nasty
 
2119
        # error page. So we redirect to launchpad.net with a notification.
 
2120
        clear_cache()
 
2121
        if not check_permission('launchpad.LimitedView', team):
 
2122
            self.request.response.addNotification(
 
2123
                "The owner of team %s was successfully changed but you are "
 
2124
                "now no longer authorised to view the team."
 
2125
                    % self.teamdisplayname)
 
2126
            self._next_url = canonical_url(self.user)
 
2127
 
2108
2128
 
2109
2129
class ITeamIndexMenu(Interface):
2110
2130
    """A marker interface for the +index navigation menu."""