def template(self):
        # Check for the magical "index" added by the browser:page template
        # machinery. If it exists this is actually the
        # zope.browserpage.simpleviewclass.simple class that is magically
        # mixed in by the browser:page zcml directive the template defined in
        # the directive should be used.
        if safe_hasattr(self, 'index'):
            return super(HasSpecificationsView, self).template

        # Sprints and Persons don't have a usage enum for blueprints, so we
        # have to fallback to the default.
        if (ISprint.providedBy(self.context)
            or IPerson.providedBy(self.context)):
            return self.default_template

        # ProjectGroups are a special case, as their products may be a
        # combination of usage settings. To deal with this, check all
        # products via the involvment menu.
        if (IProjectGroup.providedBy(self.context)
            or IProjectGroupSeries.providedBy(self.context)):
            involvement = getMultiAdapter(
                (self.context, self.request),
                name='+get-involved')
            if service_uses_launchpad(involvement.blueprints_usage):
                return self.default_template
            else:
                return self.not_launchpad_template

        # Otherwise, determine usage and provide the correct template.
        service_usage = IServiceUsage(self.context)
        if service_uses_launchpad(service_usage.blueprints_usage):
            return self.default_template
        else:
            return self.not_launchpad_template
Example #2
0
 def has_involvement(self):
     """This `IPillar` uses Launchpad."""
     return (self.official_malone
             or service_uses_launchpad(self.answers_usage)
             or service_uses_launchpad(self.blueprints_usage)
             or service_uses_launchpad(self.translations_usage)
             or service_uses_launchpad(self.codehosting_usage))
Example #3
0
 def has_involvement(self):
     """This `IPillar` uses Launchpad."""
     return (self.official_malone
             or service_uses_launchpad(self.answers_usage)
             or service_uses_launchpad(self.blueprints_usage)
             or service_uses_launchpad(self.translations_usage)
             or service_uses_launchpad(self.codehosting_usage))
    def template(self):
        # Check for the magical "index" added by the browser:page template
        # machinery. If it exists this is actually the
        # zope.browserpage.simpleviewclass.simple class that is magically
        # mixed in by the browser:page zcml directive the template defined in
        # the directive should be used.
        if safe_hasattr(self, 'index'):
            return super(HasSpecificationsView, self).template

        # Sprints and Persons don't have a usage enum for blueprints, so we
        # have to fallback to the default.
        if (ISprint.providedBy(self.context)
                or IPerson.providedBy(self.context)):
            return self.default_template

        # ProjectGroups are a special case, as their products may be a
        # combination of usage settings. To deal with this, check all
        # products via the involvment menu.
        if (IProjectGroup.providedBy(self.context)
                or IProjectGroupSeries.providedBy(self.context)):
            involvement = getMultiAdapter((self.context, self.request),
                                          name='+get-involved')
            if service_uses_launchpad(involvement.blueprints_usage):
                return self.default_template
            else:
                return self.not_launchpad_template

        # Otherwise, determine usage and provide the correct template.
        service_usage = IServiceUsage(self.context)
        if service_uses_launchpad(service_usage.blueprints_usage):
            return self.default_template
        else:
            return self.not_launchpad_template
 def uses_launchpad(self):
     """ See `IServiceUsage.`"""
     return (
         service_uses_launchpad(self.blueprints_usage) or
         service_uses_launchpad(self.translations_usage) or
         service_uses_launchpad(self.answers_usage) or
         service_uses_launchpad(self.codehosting_usage) or
         service_uses_launchpad(self.bug_tracking_usage))
Example #6
0
 def register_blueprint(self):
     return Link('+addspec',
                 'Register a blueprint',
                 site='blueprints',
                 icon='blueprints',
                 enabled=service_uses_launchpad(
                     self.pillar.blueprints_usage))
Example #7
0
 def _set_official_launchpad(self, pillar):
     """Does the pillar officially use launchpad."""
     # XXX: 2010-10-07 EdwinGrubbs bug=656292
     # Fix _set_official_launchpad().
     # This if structure is required because it may be called many
     # times to build the complete set of official applications.
     if service_uses_launchpad(IServiceUsage(pillar).bug_tracking_usage):
         self.official_malone = True
     if service_uses_launchpad(IServiceUsage(pillar).answers_usage):
         self.answers_usage = ServiceUsage.LAUNCHPAD
     if service_uses_launchpad(IServiceUsage(pillar).blueprints_usage):
         self.blueprints_usage = ServiceUsage.LAUNCHPAD
     if service_uses_launchpad(pillar.translations_usage):
         self.translations_usage = ServiceUsage.LAUNCHPAD
     if service_uses_launchpad(IServiceUsage(pillar).codehosting_usage):
         self.codehosting_usage = ServiceUsage.LAUNCHPAD
Example #8
0
    def traverse(self, name):
        """Return the IPOTemplate associated with the given name."""

        assert self.request.method in ['GET', 'HEAD', 'PATCH', 'POST'], (
            'We only know about GET, HEAD, PATCH and POST')

        # Get the requested potemplate.
        potemplate = self.context.getPOTemplateByName(name)
        if potemplate is None:
            # The template doesn't exist.
            raise NotFoundError(name)

        # Get whether the target for the requested template is officially
        # using Launchpad Translations.
        if potemplate.distribution is None:
            product_or_distro = potemplate.productseries.product
        else:
            product_or_distro = potemplate.distroseries.distribution
        translations_usage = product_or_distro.translations_usage

        if (service_uses_launchpad(translations_usage) and
           potemplate.iscurrent):
            # This template is available for translation.
            return potemplate
        elif check_permission('launchpad.TranslationsAdmin', potemplate):
            # User has Edit privileges for this template and can access it.
            return potemplate
        else:
            raise NotFoundError(name)
Example #9
0
 def _set_official_launchpad(self, pillar):
     """Does the pillar officially use launchpad."""
     # XXX: 2010-10-07 EdwinGrubbs bug=656292
     # Fix _set_official_launchpad().
     # This if structure is required because it may be called many
     # times to build the complete set of official applications.
     if service_uses_launchpad(IServiceUsage(pillar).bug_tracking_usage):
         self.official_malone = True
     if service_uses_launchpad(IServiceUsage(pillar).answers_usage):
         self.answers_usage = ServiceUsage.LAUNCHPAD
     if service_uses_launchpad(IServiceUsage(pillar).blueprints_usage):
         self.blueprints_usage = ServiceUsage.LAUNCHPAD
     if service_uses_launchpad(pillar.translations_usage):
         self.translations_usage = ServiceUsage.LAUNCHPAD
     if service_uses_launchpad(IServiceUsage(pillar).codehosting_usage):
         self.codehosting_usage = ServiceUsage.LAUNCHPAD
Example #10
0
 def register_blueprint(self):
     return Link(
         '+addspec',
         'Register a blueprint',
         site='blueprints',
         icon='blueprints',
         enabled=service_uses_launchpad(self.pillar.blueprints_usage))
Example #11
0
 def help_translate(self):
     return Link('',
                 'Help translate',
                 site='translations',
                 icon='translations',
                 enabled=service_uses_launchpad(
                     self.pillar.translations_usage))
Example #12
0
    def traverse(self, name):
        """Return the IPOTemplate associated with the given name."""

        assert self.request.method in [
            'GET', 'HEAD', 'PATCH', 'POST'
        ], ('We only know about GET, HEAD, PATCH and POST')

        # Get the requested potemplate.
        potemplate = self.context.getPOTemplateByName(name)
        if potemplate is None:
            # The template doesn't exist.
            raise NotFoundError(name)

        # Get whether the target for the requested template is officially
        # using Launchpad Translations.
        if potemplate.distribution is None:
            product_or_distro = potemplate.productseries.product
        else:
            product_or_distro = potemplate.distroseries.distribution
        translations_usage = product_or_distro.translations_usage

        if (service_uses_launchpad(translations_usage)
                and potemplate.iscurrent):
            # This template is available for translation.
            return potemplate
        elif check_permission('launchpad.TranslationsAdmin', potemplate):
            # User has Edit privileges for this template and can access it.
            return potemplate
        else:
            raise NotFoundError(name)
Example #13
0
    def translationdownload(self):
        text = 'Download'
        preferred_series = self.context.primary_translatable
        enabled = (service_uses_launchpad(self.context.translations_usage)
                   and preferred_series is not None)
        link = ''
        if enabled:
            link = canonical_url(preferred_series,
                                 rootsite='translations',
                                 view_name='+export')
            text = 'Download "%s"' % preferred_series.name

        return Link(link, text, icon='download', enabled=enabled)
Example #14
0
    def translationdownload(self):
        text = 'Download'
        preferred_series = self.context.primary_translatable
        enabled = (service_uses_launchpad(self.context.translations_usage)
            and preferred_series is not None)
        link = ''
        if enabled:
            link = canonical_url(
                preferred_series,
                rootsite='translations',
                view_name='+export')
            text = 'Download "%s"' % preferred_series.name

        return Link(link, text, icon='download', enabled=enabled)
    def template(self):
        """The template to render the presentation.

        Subclasses can redefine this property to choose their own template.
        """
        if IQuestionSet.providedBy(self.context):
            return self.default_template
        involvement = getMultiAdapter((self.context, self.request), name="+get-involved")
        if service_uses_launchpad(involvement.answers_usage):
            # Primary contexts that officially use answers have a
            # search and listing presentation.
            return self.default_template
        else:
            # Primary context that do not officially use answers have an
            # an explanation about about the current state.
            return self.unknown_template
Example #16
0
    def template(self):
        """The template to render the presentation.

        Subclasses can redefine this property to choose their own template.
        """
        if IQuestionSet.providedBy(self.context):
            return self.default_template
        involvement = getMultiAdapter((self.context, self.request),
                                      name='+get-involved')
        if service_uses_launchpad(involvement.answers_usage):
            # Primary contexts that officially use answers have a
            # search and listing presentation.
            return self.default_template
        else:
            # Primary context that do not officially use answers have an
            # an explanation about about the current state.
            return self.unknown_template
Example #17
0
 def show_page_content(self):
     """Whether the main content of the page should be shown."""
     return (service_uses_launchpad(self.context.translations_usage)
             or self.is_translations_admin)
Example #18
0
 def help_translate(self):
     return Link(
         '', 'Help translate', site='translations', icon='translations',
         enabled=service_uses_launchpad(self.pillar.translations_usage))
Example #19
0
 def show_page_content(self):
     """Whether the main content of the page should be shown."""
     return service_uses_launchpad(self.context.translations_usage) or self.is_translations_admin
Example #20
0
 def uses_translations(self):
     """Whether this product has translatable templates."""
     return (service_uses_launchpad(self.context.translations_usage)
             and self.primary_translatable is not None)
Example #21
0
 def no_translations_available(self):
     """Has no translation templates but does support translations."""
     return (service_uses_launchpad(self.context.translations_usage)
             and self.primary_translatable is None)
Example #22
0
 def ask_question(self):
     return Link(
         '+addquestion', 'Ask a question', site='answers', icon='answers',
         enabled=service_uses_launchpad(self.pillar.answers_usage))
Example #23
0
 def uses_translations(self):
     """Whether this product has translatable templates."""
     return (service_uses_launchpad(self.context.translations_usage)
             and self.primary_translatable is not None)
Example #24
0
 def ask_question(self):
     return Link('+addquestion',
                 'Ask a question',
                 site='answers',
                 icon='answers',
                 enabled=service_uses_launchpad(self.pillar.answers_usage))
Example #25
0
 def no_translations_available(self):
     """Has no translation templates but does support translations."""
     return (service_uses_launchpad(self.context.translations_usage)
             and self.primary_translatable is None)