~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2009-08-12 05:41:13 UTC
  • mfrom: (9084.1.12 branch-form-3-0)
  • Revision ID: launchpad@pqm.canonical.com-20090812054113-576wcgrdh47jmap7
[r=rockstar,deryck][ui=rs] Some 3.0 updates for some branch pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    'BugBranchPrimaryContext',
12
12
    ]
13
13
 
14
 
from zope.event import notify
15
14
from zope.interface import implements
16
15
 
17
 
from lazr.lifecycle.event import ObjectDeletedEvent
 
16
from canonical.lazr.utils import smartquote
18
17
 
19
18
from canonical.launchpad import _
20
 
from lp.bugs.interfaces.bugbranch import IBugBranch
21
19
from canonical.launchpad.webapp import (
22
 
    action, canonical_url, custom_widget, LaunchpadEditFormView,
23
 
    LaunchpadFormView)
 
20
    action, canonical_url, LaunchpadEditFormView, LaunchpadFormView)
24
21
from canonical.launchpad.webapp.interfaces import IPrimaryContext
25
 
 
26
 
from canonical.widgets.link import LinkWidget
 
22
from lp.bugs.interfaces.bugbranch import IBugBranch
27
23
 
28
24
 
29
25
class BugBranchPrimaryContext:
92
88
    field_names = ['bug']
93
89
 
94
90
    @property
 
91
    def label(self):
 
92
        return "Link to a bug report"
 
93
 
 
94
    @property
 
95
    def page_title(self):
 
96
        return smartquote(
 
97
            'Link branch "%s" to a bug report' % self.context.displayname)
 
98
 
 
99
    @property
95
100
    def next_url(self):
96
101
        return canonical_url(self.context)
97
102
 
 
103
    cancel_url = next_url
 
104
 
98
105
    @action(_('Continue'), name='continue')
99
106
    def continue_action(self, action, data):
100
107
        bug = data['bug']
101
108
        bug_branch = bug.linkBranch(
102
109
            branch=self.context, registrant=self.user)
103
 
 
104
 
    @action(_('Cancel'), name='cancel', validator='validate_cancel')
105
 
    def cancel_action(self, action, data):
106
 
        """Do nothing and go back to the branch page."""
107
 
 
108
 
    def validate(self, data):
109
 
        """Make sure that this bug isn't already linked to the branch."""
110
 
        if 'bug' not in data:
111
 
            return
112
 
 
113
 
        link_bug = data['bug']