~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-05-18 18:50:39 UTC
  • mfrom: (13033.2.4 bug-777786)
  • Revision ID: launchpad@pqm.canonical.com-20110518185039-h7f6fmiryyo7a2np
[r=gmb][bug=777786] instead of an ineffectual "stop email" link,
        give users the option to contact the subscribing team

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
    'StructuralSubscribersPortletView',
15
15
    ]
16
16
 
17
 
from operator import attrgetter
 
17
from operator import (
 
18
    attrgetter,
 
19
    itemgetter,
 
20
    )
18
21
 
19
22
from lazr.restful.interfaces import (
20
23
    IJSONRequestCache,
491
494
        subscriber = subscription.subscriber
492
495
        for filter in subscription.bug_filters:
493
496
            is_team = subscriber.isTeam()
494
 
            user_is_team_admin = (is_team and
495
 
                                  subscriber in administered_teams)
 
497
            user_is_team_admin = (
 
498
                is_team and subscriber in administered_teams)
 
499
            team_has_contact_address = (
 
500
                is_team and subscriber.preferredemail is not None)
 
501
            mailing_list = subscriber.mailing_list
 
502
            user_is_on_team_mailing_list = (
 
503
                team_has_contact_address and
 
504
                mailing_list is not None and
 
505
                mailing_list.is_usable and
 
506
                mailing_list.getSubscription(subscriber) is not None)
496
507
            record['filters'].append(dict(
497
508
                filter=filter,
498
509
                subscriber_link=absoluteURL(subscriber, api_request),
499
 
                subscriber_url = canonical_url(
 
510
                subscriber_url=canonical_url(
500
511
                    subscriber, rootsite='mainsite'),
 
512
                target_bugs_url=canonical_url(
 
513
                    target, rootsite='bugs'),
501
514
                subscriber_title=subscriber.title,
502
515
                subscriber_is_team=is_team,
503
516
                user_is_team_admin=user_is_team_admin,
 
517
                team_has_contact_address=team_has_contact_address,
 
518
                user_is_on_team_mailing_list=user_is_on_team_mailing_list,
504
519
                can_mute=filter.isMuteAllowed(user),
505
 
                is_muted=filter.muted(user) is not None))
 
520
                is_muted=filter.muted(user) is not None,
 
521
                target_title=target.title))
506
522
    info = info.values()
507
 
    info.sort(key=lambda item: item['target_url'])
 
523
    info.sort(key=itemgetter('target_url'))
508
524
    IJSONRequestCache(request).objects['subscription_info'] = info
509
525
 
510
526