~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/browser/branch.py

[r=Edwin][ui=None] BranchUpgradeJob refactoring for 2.0 changes,
        UI for requesting an upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    'BranchEditMenu',
21
21
    'BranchInProductView',
22
22
    'BranchSparkView',
 
23
    'BranchUpgradeView',
23
24
    'BranchURL',
24
25
    'BranchView',
25
26
    'BranchSubscriptionsView',
223
224
    links = [
224
225
        'add_subscriber', 'browse_revisions', 'link_bug',
225
226
        'link_blueprint', 'register_merge', 'source', 'subscription',
226
 
        'edit_status', 'edit_import']
 
227
        'edit_status', 'edit_import', 'upgrade_branch']
227
228
 
228
229
    @enabled_with_permission('launchpad.Edit')
229
230
    def edit_status(self):
299
300
        return Link(
300
301
            '+edit-import', text, icon='edit', enabled=enabled)
301
302
 
 
303
    @enabled_with_permission('launchpad.Edit')
 
304
    def upgrade_branch(self):
 
305
        enabled = False
 
306
        if self.context.needs_upgrading:
 
307
            enabled = True
 
308
        return Link(
 
309
            '+upgrade', 'Upgrade this branch', icon='edit', enabled=enabled)
 
310
 
302
311
 
303
312
class DecoratedBug:
304
313
    """Provide some additional attributes to a normal bug."""
878
887
        return canonical_url(self.context)
879
888
 
880
889
 
 
890
class BranchUpgradeView(LaunchpadFormView):
 
891
    """Used to upgrade a branch."""
 
892
 
 
893
    schema = IBranch
 
894
    field_names = []
 
895
 
 
896
    @property
 
897
    def page_title(self):
 
898
        return smartquote('Upgrade branch "%s"' % self.context.displayname)
 
899
 
 
900
    @property
 
901
    def next_url(self):
 
902
        return canonical_url(self.context)
 
903
 
 
904
    cancel_url = next_url
 
905
 
 
906
    @action('Upgrade', name='upgrade_branch')
 
907
    def upgrade_branch_action(self, action, data):
 
908
        self.context.requestUpgrade()
 
909
 
 
910
 
881
911
class BranchEditView(BranchEditFormView, BranchNameValidationMixin):
882
912
    """The main branch view for editing the branch attributes."""
883
913