11
11
'SpecificationDependencyTreeView',
14
from zope.formlib import form
15
from zope.schema import Choice
14
from zope.interface import Interface
16
from lazr.restful.interface import copy_field
17
18
from canonical.launchpad import _
18
19
from canonical.launchpad.webapp import (
31
class AddSpecificationDependencySchema(Interface):
33
dependency = copy_field(
34
ISpecificationDependency['dependency'],
37
"If another blueprint needs to be fully implemented "
38
"before this feature can be started, then specify that "
39
"dependency here so Launchpad knows about it and can "
40
"give you an accurate project plan."))
30
43
class SpecificationDependencyAddView(LaunchpadFormView):
31
schema = ISpecificationDependency
32
field_names = ['dependency']
44
schema = AddSpecificationDependencySchema
33
45
label = _('Depends On')
35
def setUpFields(self):
36
"""Override the setup to define own fields."""
37
self.form_fields = form.Fields(
39
__name__='dependency',
40
title=_(u'Depends On'),
41
vocabulary='SpecificationDepCandidates',
44
"If another blueprint needs to be fully implemented "
45
"before this feature can be started, then specify that "
46
"dependency here so Launchpad knows about it and can "
47
"give you an accurate project plan.")),
48
render_context=self.render_context)
50
47
def validate(self, data):
52
token = self.request.form.get(self.widgets['dependency'].name)
54
self.widgets['dependency'].vocabulary.getTermByToken(token)
48
"""See `LaunchpadFormView.validate`.
50
Because it's too hard to set a good error message from inside the
51
widget -- it will be the infamously inscrutable 'Invalid Value' -- we
54
if self.getFieldError('dependency'):
55
token = self.request.form.get(self.widgets['dependency'].name)
58
56
self.setFieldError(
60
58
'There is no blueprint named "%s" in %s, or '