~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-05 06:40:47 UTC
  • mfrom: (13453.5.6 dsp-picker-fields)
  • Revision ID: launchpad@pqm.canonical.com-20110805064047-4e6y0rwp4nqh8my2
[r=sinzui][bug=618366] Switch to using the DSP vocab when a feature
 flag is turned on for retargetting a bug or question.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
__metaclass__ = type
5
5
 
6
 
__all__ = ['BugAlsoAffectsProductMetaView', 'BugAlsoAffectsDistroMetaView',
7
 
           'BugAlsoAffectsProductWithProductCreationView']
 
6
__all__ = [
 
7
    'BugAlsoAffectsProductMetaView',
 
8
    'BugAlsoAffectsDistroMetaView',
 
9
    'BugAlsoAffectsProductWithProductCreationView'
 
10
    ]
8
11
 
9
12
import cgi
10
13
from textwrap import dedent
14
17
    Item,
15
18
    )
16
19
from lazr.lifecycle.event import ObjectCreatedEvent
 
20
from lazr.restful.interface import copy_field
17
21
from z3c.ptcompat import ViewPageTemplateFile
18
22
from zope.app.form.browser import DropdownWidget
19
23
from zope.app.form.interfaces import MissingInputError
41
45
    )
42
46
from lp.app.enums import ServiceUsage
43
47
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
44
 
from lp.app.validators import LaunchpadValidationError
45
48
from lp.app.validators.email import email_validator
46
49
from lp.app.widgets.itemswidgets import LaunchpadRadioWidget
47
50
from lp.app.widgets.popup import SearchForUpstreamPopupWidget
82
85
    IProductSet,
83
86
    License,
84
87
    )
 
88
from lp.services.features import getFeatureFlag
85
89
from lp.services.fields import StrippedTextLine
86
90
from lp.services.propertycache import cachedproperty
87
91
 
352
356
    label = "Also affects distribution/package"
353
357
    target_field_names = ('distribution', 'sourcepackagename')
354
358
 
 
359
    def setUpFields(self):
 
360
        super(DistroBugTaskCreationStep, self).setUpFields()
 
361
        if bool(getFeatureFlag('disclosure.dsp_picker.enabled')):
 
362
            # Replace the default field with a field that uses the better
 
363
            # vocabulary.
 
364
            self.form_fields = self.form_fields.omit('sourcepackagename')
 
365
            new_sourcepackagename = copy_field(
 
366
                IAddBugTaskForm['sourcepackagename'],
 
367
                vocabulary='DistributionSourcePackage')
 
368
            self.form_fields += form.Fields(new_sourcepackagename)
 
369
 
355
370
    @property
356
371
    def initial_values(self):
357
372
        """Return the initial values for the view's fields."""