def initialize(self):
        """Remove some fields based on the entry handled."""
        self.field_names = [
            "file_type",
            "path",
            "sourcepackagename",
            "potemplate",
            "potemplate_name",
            "name",
            "translation_domain",
            "languagepack",
            "language",
        ]

        if self.context.productseries is not None:
            # We are handling an entry for a productseries, this field is not
            # useful here.
            self.field_names.remove("sourcepackagename")

        if not self.context.is_targeted_to_ubuntu:
            # Only show languagepack for Ubuntu packages.
            self.field_names.remove("languagepack")

        # Execute default initialization.
        LaunchpadFormView.initialize(self)
 def setUpFields(self):
     """See `LaunchpadFormView`."""
     LaunchpadFormView.setUpFields(self)
     self.form_fields += self.createRequireVirtualized()
     self.form_fields += self.createEnabledRestrictedProcessors(
         u"The restricted architectures on which the distribution's main " "archive can build."
     )
Exemple #3
0
 def initialize(self):
     """Initialize the view to handle the request."""
     LaunchpadFormView.initialize(self)
     bug_id = self.request.form.get("id")
     if bug_id:
         self._redirectToBug(bug_id)
     elif self.widgets['scope'].hasInput():
         self._validate(action=None, data={})
 def setUpWidgets(self):
     """See `LaunchpadFormView`."""
     LaunchpadFormView.setUpWidgets(self)
     # Make sure that the default filter is displayed
     # correctly in the widgets when not overridden by the user
     for name, value in self.getDefaultFilter().items():
         widget = self.widgets.get(name)
         if widget and not widget.hasValidInput():
             widget.setRenderedValue(value)
Exemple #5
0
 def setUpWidgets(self):
     LaunchpadFormView.setUpWidgets(self)
     timeformat = '%Y-%m-%d %H:%M'
     self.widgets['time_starts'].timeformat = timeformat
     self.widgets['time_ends'].timeformat = timeformat
     time_zone_widget = self.widgets['time_zone']
     if time_zone_widget.hasValidInput():
         tz = pytz.timezone(time_zone_widget.getInputValue())
         self.widgets['time_starts'].required_time_zone = tz
         self.widgets['time_ends'].required_time_zone = tz
 def initialize(self):
     """Initialize the view when a Bug may be reported for the Question."""
     question = self.context
     if question.bugs:
         # we can't make a bug when we have linked bugs
         self.request.response.addErrorNotification(
             _('You cannot create a bug report from a question'
               'that already has bugs linked to it.'))
         self.request.response.redirect(canonical_url(question))
         return
     LaunchpadFormView.initialize(self)
Exemple #7
0
    def initialize(self):
        """See `LaunchpadFormView`."""
        LaunchpadFormView.initialize(self)

        self.language_search = None

        search_lang_widget = self.widgets.get('search_lang')
        if (search_lang_widget is not None and
            search_lang_widget.hasValidInput()):
            self.language_search = search_lang_widget.getInputValue()
        self.search_requested = self.language_search is not None
 def initialize(self):
     LaunchpadFormView.initialize(self)
     # Update the submit label based on the user's permission.
     submit_action = self.__class__.actions.byname["actions.submit"]
     if self.userIsReleaseManager():
         submit_action.label = _("Target")
     elif self.userIsBugSupervisor():
         submit_action.label = _("Nominate")
     else:
         self.request.response.addErrorNotification("You do not have permission to nominate this bug.")
         self.request.response.redirect(canonical_url(self.current_bugtask))
 def setUpFields(self):
     """See LaunchpadFormView."""
     LaunchpadFormView.setUpFields(self)
     team_subscriptions = self._createTeamSubscriptionsField()
     if team_subscriptions:
         self.form_fields += form.Fields(team_subscriptions)
     if self.userIsDriver():
         add_other = form.Fields(self._createAddOtherSubscriptionsField())
         self.form_fields += add_other
         remove_other = self._createRemoveOtherSubscriptionsField()
         if remove_other:
             self.form_fields += form.Fields(remove_other)
    def setUpFields(self):
        """See `LaunchpadFormView`."""
        LaunchpadFormView.setUpFields(self)
        # setup filter fields.
        target_field = self.createFilterTargetField()
        if target_field is not None:
            self.form_fields = (target_field + self.form_fields)

        self.form_fields = (
            self.createFilterStatusField() +
            self.createFilterFileExtensionField() +
            self.form_fields)
Exemple #11
0
    def initialize(self):
        """See `ILaunchpadFormView`.

        It redirects attempts to rescore builds that cannot be rescored
        to the build context page, so the current page-scrapping libraries
        won't cause any oops.

        It also sets next_url and cancel_url to the build context page, so
        any action will send the user back to the context build page.
        """
        build_url = canonical_url(self.context)
        self.next_url = self.cancel_url = build_url

        if not self.context.can_be_rescored:
            self.request.response.redirect(build_url)

        LaunchpadFormView.initialize(self)
Exemple #12
0
 def setUpWidgets(self):
     LaunchpadFormView.setUpWidgets(self)
     tz = pytz.timezone(self.context.time_zone)
     self.starts_widget = self.widgets['time_starts']
     self.ends_widget = self.widgets['time_ends']
     self.starts_widget.required_time_zone = tz
     self.ends_widget.required_time_zone = tz
     # We don't need to display seconds
     timeformat = '%Y-%m-%d %H:%M'
     self.starts_widget.timeformat = timeformat
     self.ends_widget.timeformat = timeformat
     # Constrain the widget to dates from the day before to the day
     # after the sprint. We will accept a time just before or just after
     # and map those to the beginning and end times, respectively, in
     # self.getDates().
     from_date = self.context.time_starts.astimezone(tz)
     to_date = self.context.time_ends.astimezone(tz)
     self.starts_widget.from_date = from_date - timedelta(days=1)
     self.starts_widget.to_date = to_date
     self.ends_widget.from_date = from_date
     self.ends_widget.to_date = to_date + timedelta(days=1)
 def setUpWidgets(self):
     LaunchpadFormView.setUpWidgets(self)
     tz = pytz.timezone(self.context.time_zone)
     self.starts_widget = self.widgets['time_starts']
     self.ends_widget = self.widgets['time_ends']
     self.starts_widget.required_time_zone = tz
     self.ends_widget.required_time_zone = tz
     # We don't need to display seconds
     timeformat = '%Y-%m-%d %H:%M'
     self.starts_widget.timeformat = timeformat
     self.ends_widget.timeformat = timeformat
     # Constrain the widget to dates from the day before to the day
     # after the sprint. We will accept a time just before or just after
     # and map those to the beginning and end times, respectively, in
     # self.getDates().
     from_date = self.context.time_starts.astimezone(tz)
     to_date = self.context.time_ends.astimezone(tz)
     self.starts_widget.from_date = from_date - timedelta(days=1)
     self.starts_widget.to_date = to_date
     self.ends_widget.from_date = from_date
     self.ends_widget.to_date = to_date + timedelta(days=1)
    def test_formLayout(self):
        # Verify that exactly one of isSingleLineLayout(), isMultiLineLayout()
        # and isCheckBoxLayout() return True for particular widget.
        #
        # If more than one returns True, then that widget may get included
        # in the form twice.
        form = LaunchpadFormView(None, None)
        class FakeWidget:
            pass
        widget = FakeWidget()
        form.widgets = {'widget': widget}
        # test every combination of the three interfaces:
        for use_single_line in [False, True]:
            for use_multi_line in [False, True]:
                for use_checkbox in [False, True]:
                    provides = []
                    if use_single_line:
                        provides.append(ISingleLineWidgetLayout)
                    if use_multi_line:
                        provides.append(IMultiLineWidgetLayout)
                    if use_checkbox:
                        provides.append(ICheckBoxWidgetLayout)
                    directlyProvides(widget, *provides)

                    # Now count how many of the is* functions return True:
                    count = 0
                    if form.isSingleLineLayout('widget'):
                        count += 1
                    if form.isMultiLineLayout('widget'):
                        count += 1
                    if form.isCheckBoxLayout('widget'):
                        count += 1

                    self.assertEqual(count, 1,
                                     'Expected count of 1 for %r.  Got %d'
                                     % (provides, count))
 def test_showOptionalMarker(self):
     """Verify a field marked .for_display has no (Optional) marker."""
     # IInputWidgets have an (Optional) marker if they are not required.
     form = LaunchpadFormView(None, None)
     class FakeInputWidget:
         implements(IInputWidget)
         def __init__(self, required):
             self.required = required
     form.widgets = {'widget': FakeInputWidget(required=False)}
     self.assertTrue(form.showOptionalMarker('widget'))
     # Required IInputWidgets have no (Optional) marker.
     form.widgets = {'widget': FakeInputWidget(required=True)}
     self.assertFalse(form.showOptionalMarker('widget'))
     # IDisplayWidgets have no (Optional) marker, regardless of whether
     # they are required or not, since they are read only.
     class FakeDisplayWidget:
         implements(IDisplayWidget)
         def __init__(self, required):
             self.required = required
     form.widgets = {'widget': FakeDisplayWidget(required=False)}
     self.assertFalse(form.showOptionalMarker('widget'))
     form.widgets = {'widget': FakeDisplayWidget(required=True)}
     self.assertFalse(form.showOptionalMarker('widget'))
    def test_formLayout(self):
        # Verify that exactly one of isSingleLineLayout(), isMultiLineLayout()
        # and isCheckBoxLayout() return True for particular widget.
        #
        # If more than one returns True, then that widget may get included
        # in the form twice.
        form = LaunchpadFormView(None, None)

        class FakeWidget:
            pass

        widget = FakeWidget()
        form.widgets = {'widget': widget}
        # test every combination of the three interfaces:
        for use_single_line in [False, True]:
            for use_multi_line in [False, True]:
                for use_checkbox in [False, True]:
                    provides = []
                    if use_single_line:
                        provides.append(ISingleLineWidgetLayout)
                    if use_multi_line:
                        provides.append(IMultiLineWidgetLayout)
                    if use_checkbox:
                        provides.append(ICheckBoxWidgetLayout)
                    directlyProvides(widget, *provides)

                    # Now count how many of the is* functions return True:
                    count = 0
                    if form.isSingleLineLayout('widget'):
                        count += 1
                    if form.isMultiLineLayout('widget'):
                        count += 1
                    if form.isCheckBoxLayout('widget'):
                        count += 1

                    self.assertEqual(
                        count, 1, 'Expected count of 1 for %r.  Got %d' %
                        (provides, count))
 def __init__(self, context, request):
     self.current_bugtask = context
     LaunchpadFormView.__init__(self, context, request)
 def setUpFields(self):
     """See `LaunchpadFormView`."""
     LaunchpadFormView.setUpFields(self)
     if self.show_language_control:
         self.form_fields = self.createLanguageField() + self.form_fields
 def initialize(self):
     """See `LaunchpadFormView`."""
     self._initial_values = {}
     LaunchpadFormView.initialize(self)
 def __init__(self, context, request):
     LaunchpadFormView.__init__(self, context, request)
     self.next_url = self.cancel_url = (
         canonical_url(ICanonicalUrlData(context).inside))
Exemple #21
0
 def setUpFields(self):
     """See `LaunchpadFormView`."""
     LaunchpadFormView.setUpFields(self)
     if self.show_language_control:
         self.form_fields = self.createLanguageField() + self.form_fields
 def __init__(self, context, request):
     self.current_bugtask = context
     LaunchpadFormView.__init__(self, context, request)
Exemple #23
0
 def initialize(self):
     """Show a 404 if the branch target doesn't support proposals."""
     if not self.context.target.supports_merge_proposals:
         raise NotFound(self.context, '+register-merge')
     LaunchpadFormView.initialize(self)
Exemple #24
0
 def render(self):
     """See ILaunchpadFormView."""
     if self.errors:
         self.setHeadersForHWDBClient()
     return LaunchpadFormView.render(self)
 def initialize(self):
     """See `LaunchpadFormView`."""
     self._initial_values = {}
     LaunchpadFormView.initialize(self)
Exemple #26
0
 def __init__(self, context, request):
     LaunchpadFormView.__init__(self, context, request)
     self.next_url = self.cancel_url = (
         canonical_url(ICanonicalUrlData(context).inside))
Exemple #27
0
 def render(self):
     """See ILaunchpadFormView."""
     if self.errors:
         self.setHeadersForHWDBClient()
     return LaunchpadFormView.render(self)