1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Views for SpecificationDependency."""
__metaclass__ = type
__all__ = [
'SpecificationDependencyAddView',
'SpecificationDependencyRemoveView',
'SpecificationDependencyTreeView',
]
from lazr.restful.interface import copy_field
from zope.interface import Interface
from lp import _
from lp.app.browser.launchpadform import (
action,
LaunchpadFormView,
)
from lp.blueprints.interfaces.specificationdependency import (
ISpecificationDependency,
ISpecificationDependencyRemoval,
)
from lp.services.webapp import (
canonical_url,
LaunchpadView,
)
class AddSpecificationDependencySchema(Interface):
dependency = copy_field(
ISpecificationDependency['dependency'],
readonly=False,
description=_(
"If another blueprint needs to be fully implemented "
"before this feature can be started, then specify that "
"dependency here so Launchpad knows about it and can "
"give you an accurate project plan. You can enter the "
"name of a blueprint that has the same target, or the "
"URL of any blueprint."))
class SpecificationDependencyAddView(LaunchpadFormView):
schema = AddSpecificationDependencySchema
label = _('Depends On')
def validate(self, data):
"""See `LaunchpadFormView.validate`.
Because it's too hard to set a good error message from inside the
widget -- it will be the infamously inscrutable 'Invalid Value' -- we
replace it here.
"""
if self.getFieldError('dependency'):
token = self.request.form.get(self.widgets['dependency'].name)
self.setFieldError(
'dependency',
'There is no blueprint named "%s" in %s, or '
'%s isn\'t valid dependency of that blueprint.' %
(token, self.context.target.name, self.context.name))
@action(_('Continue'), name='linkdependency')
def linkdependency_action(self, action, data):
self.context.createDependency(data['dependency'])
@property
def next_url(self):
return canonical_url(self.context)
@property
def cancel_url(self):
return canonical_url(self.context)
class SpecificationDependencyRemoveView(LaunchpadFormView):
schema = ISpecificationDependencyRemoval
label = 'Remove a dependency'
field_names = ['dependency']
for_input = True
@action('Continue', name='continue')
def continue_action(self, action, data):
self.context.removeDependency(data['dependency'])
self.next_url = canonical_url(self.context)
@property
def cancel_url(self):
return canonical_url(self.context)
class SpecificationDependencyTreeView(LaunchpadView):
label = "Blueprint dependency tree"
@property
def page_title(self):
return self.label
|