~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/browser/structuralsubscription.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-04-21 21:53:27 UTC
  • mfrom: (12888.1.4 owner_administrator)
  • Revision ID: launchpad@pqm.canonical.com-20110421215327-wexu8agur9yhut2m
[r=benji][bug=768366] change the structural subscription overlay to
        not allow the current user to subscribe teams that they own but
        are not members of

Show diffs side-by-side

added added

removed removed

Lines of Context:
428
428
    api_request = IWebServiceClientRequest(request)
429
429
    is_distro = IDistribution.providedBy(context)
430
430
    if user is not None:
431
 
        for team in user.getAdministratedTeams():
432
 
            # If the context is a distro AND a bug supervisor is set AND
433
 
            # the admininistered team is not a member of the bug supervisor
434
 
            # team THEN skip it.
435
 
            if (is_distro and context.bug_supervisor is not None and
436
 
                not team.inTeam(context.bug_supervisor)):
437
 
                continue
438
 
            info.append({
439
 
                'link': absoluteURL(team, api_request),
440
 
                'title': team.title,
441
 
                'url': canonical_url(team),
442
 
            })
 
431
        administrated_teams = list(user.getAdministratedTeams())
 
432
        if administrated_teams:
 
433
            # Get this only if we need to.
 
434
            membership = list(user.teams_participated_in)
 
435
            for team in administrated_teams:
 
436
                # If the user is not a member of the team itself, then skip it,
 
437
                # because structural subscriptions and their filters can only be
 
438
                # edited by the subscriber.
 
439
                # This can happen if the user is an owner but not a member.
 
440
                if not team in membership:
 
441
                    continue
 
442
                # If the context is a distro AND a bug supervisor is set AND
 
443
                # the admininistered team is not a member of the bug supervisor
 
444
                # team THEN skip it.
 
445
                if (is_distro and context.bug_supervisor is not None and
 
446
                    not team.inTeam(context.bug_supervisor)):
 
447
                    continue
 
448
                info.append({
 
449
                    'link': absoluteURL(team, api_request),
 
450
                    'title': team.title,
 
451
                    'url': canonical_url(team),
 
452
                })
443
453
    IJSONRequestCache(request).objects['administratedTeams'] = info
444
454
 
445
455