Example #1
0
    def validate(self, data):
        # Normalise aliases to an empty list if it's None.
        if data.get('aliases') is None:
            data['aliases'] = []

        # If aliases has an error, unwrap the Dantean exception from
        # Zope so that we can tell the user something useful.
        if self.getFieldError('aliases'):
            # XXX: wgrant 2008-04-02 bug=210901: The error
            # messages may have already been escaped by
            # LaunchpadValidationError, so wrap them in structured() to
            # avoid double-escaping them. It's possible that non-LVEs
            # could also be escaped, but I can't think of any cases so
            # let's just escape them anyway.
            aliases_errors = self.widgets['aliases']._error.errors.args[0]
            maybe_structured_errors = [
                structured(error)
                if isinstance(error, LaunchpadValidationError) else error
                for error in aliases_errors
            ]
            self.setFieldError(
                'aliases',
                structured(
                    '<br />'.join(['%s'] * len(maybe_structured_errors)),
                    *maybe_structured_errors))
Example #2
0
 def complete_action(self, action, data):
     if not data.get('discharge_macaroon'):
         self.addError(structured(
             _(u'Uploads of %(snap)s to the store were not authorized.'),
             snap=self.context.name))
         return
     self.context.completeAuthorization(
         discharge_macaroon=data['discharge_macaroon'])
     self.request.response.addInfoNotification(structured(
         _(u'Uploads of %(snap)s to the store are now authorized.'),
         snap=self.context.name))
     self.request.response.redirect(canonical_url(self.context))
Example #3
0
 def linktocve(self):
     """Return the 'Link to CVE' Link."""
     text = structured(
         'Link to '
         '<abbr title="Common Vulnerabilities and Exposures Index">'
         'CVE'
         '</abbr>')
     return Link('+linkcve', text, icon='add')
 def initialize(self):
     super(SourcePackageRecipeView, self).initialize()
     recipe = self.context
     if recipe.build_daily and recipe.daily_build_archive is None:
         self.request.response.addWarningNotification(
             structured(
                 "Daily builds for this recipe will <strong>not</strong> "
                 "occur.<br/><br/>There is no PPA."))
     elif self.dailyBuildWithoutUploadPermission():
         self.request.response.addWarningNotification(
             structured(
                 "Daily builds for this recipe will <strong>not</strong> "
                 "occur.<br/><br/>The owner of the recipe (%s) does not "
                 "have permission to upload packages into the daily "
                 "build PPA (%s)" % (
                     format_link(recipe.owner),
                     format_link(recipe.daily_build_archive))))
Example #5
0
 def initialize(self):
     super(SourcePackageRecipeView, self).initialize()
     recipe = self.context
     if recipe.build_daily and recipe.daily_build_archive is None:
         self.request.response.addWarningNotification(
             structured(
                 "Daily builds for this recipe will <strong>not</strong> "
                 "occur.<br/><br/>There is no PPA."))
     elif self.dailyBuildWithoutUploadPermission():
         self.request.response.addWarningNotification(
             structured(
                 "Daily builds for this recipe will <strong>not</strong> "
                 "occur.<br/><br/>The owner of the recipe (%s) does not "
                 "have permission to upload packages into the daily "
                 "build PPA (%s)" %
                 (format_link(recipe.owner),
                  format_link(recipe.daily_build_archive))))
Example #6
0
def new_builds_notification_text(builds, already_pending=None):
    nr_builds = len(builds)
    if not nr_builds:
        builds_text = "All requested builds are already queued."
    elif nr_builds == 1:
        builds_text = "1 new build has been queued."
    else:
        builds_text = "%d new builds have been queued." % nr_builds
    if nr_builds and already_pending:
        return structured("<p>%s</p><p>%s</p>", builds_text, already_pending)
    else:
        return builds_text
Example #7
0
    def validate(self, data):
        # Normalise aliases to an empty list if it's None.
        if data.get('aliases') is None:
            data['aliases'] = []

        # If aliases has an error, unwrap the Dantean exception from
        # Zope so that we can tell the user something useful.
        if self.getFieldError('aliases'):
            # XXX: wgrant 2008-04-02 bug=210901: The error
            # messages may have already been escaped by
            # LaunchpadValidationError, so wrap them in structured() to
            # avoid double-escaping them. It's possible that non-LVEs
            # could also be escaped, but I can't think of any cases so
            # let's just escape them anyway.
            aliases_errors = self.widgets['aliases']._error.errors.args[0]
            maybe_structured_errors = [
                structured(error)
                if isinstance(error, LaunchpadValidationError) else error
                for error in aliases_errors]
            self.setFieldError('aliases', structured(
                    '<br />'.join(['%s'] * len(maybe_structured_errors)),
                    *maybe_structured_errors))
def new_builds_notification_text(builds, already_pending=None,
                                 contains_unbuildable=False):
    nr_builds = len(builds)
    if not nr_builds:
        builds_text = "All requested recipe builds are already queued."
    elif nr_builds == 1:
        builds_text = "1 new recipe build has been queued."
    else:
        builds_text = "%d new recipe builds have been queued." % nr_builds
    if nr_builds > 0 and already_pending:
        builds_text = "<p>%s</p>%s" % (builds_text, already_pending)
    if contains_unbuildable:
        builds_text = ("%s<p>The recipe contains an obsolete distroseries, "
            "which has been skipped.</p>" % builds_text)
    return structured(builds_text)
Example #9
0
def new_builds_notification_text(builds,
                                 already_pending=None,
                                 contains_unbuildable=False):
    nr_builds = len(builds)
    if not nr_builds:
        builds_text = "All requested recipe builds are already queued."
    elif nr_builds == 1:
        builds_text = "1 new recipe build has been queued."
    else:
        builds_text = "%d new recipe builds have been queued." % nr_builds
    if nr_builds > 0 and already_pending:
        builds_text = "<p>%s</p>%s" % (builds_text, already_pending)
    if contains_unbuildable:
        builds_text = ("%s<p>The recipe contains an obsolete distroseries, "
                       "which has been skipped.</p>" % builds_text)
    return structured(builds_text)
Example #10
0
    def _handlePrivacyChanged(self, user_will_be_subscribed):
        """Handle the case where the privacy of the bug has been changed.

        If the bug has been made private and the user is not a direct
        subscriber, they will be subscribed. If the bug is being made
        public or the user is already directly subscribed, this is a
        no-op.
        """
        if user_will_be_subscribed:
            notification_text = (
                    "Since you marked this bug as private you have "
                    "automatically been subscribed to it. "
                    "If you don't want to receive email about "
                    "this bug you can <a href=\"%s\">mute your "
                    "subscription</a> or <a href=\"%s\">"
                    "unsubscribe</a>." % (
                    canonical_url(
                        self.context, view_name='+mute'),
                    canonical_url(
                        self.context, view_name='+subscribe')))
            self.request.response.addInfoNotification(
                structured(notification_text))
Example #11
0
 def rdf(self):
     text = structured(
         'Download <abbr title="Resource Description Framework">'
         'RDF</abbr> metadata')
     return Link('+rdf', text, icon='download-icon')
Example #12
0
 def rdf(self):
     text = structured(
         'Download <abbr title="Resource Description Framework">'
         'RDF</abbr> metadata')
     return Link('+rdf', text, icon='download-icon')