示例#1
0
    def page_title(self):
        """Heading to display above the search results."""

        if IQuestionSet.providedBy(self.context):
            return _('Questions matching "${search_text}"',
                     mapping=dict(search_text=self.search_text))

        replacements = dict(context=self.context.displayname,
                            search_text=self.search_text)
        # Check if the set of selected status has a special title.
        status_set_title = self.status_title_map.get(
            frozenset(self.status_filter))
        if status_set_title:
            replacements['status'] = status_set_title
            if self.search_text:
                return _(
                    '${status} questions matching "${search_text}" '
                    'for ${context}',
                    mapping=replacements)
            else:
                return _('${status} questions for ${context}',
                         mapping=replacements)
        else:
            if self.search_text:
                return _(
                    'Questions matching "${search_text}" for '
                    '${context}',
                    mapping=replacements)
            else:
                return _('Questions for ${context}', mapping=replacements)
    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
示例#3
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
    def page_title(self):
        """Heading to display above the search results."""

        if IQuestionSet.providedBy(self.context):
            return _('Questions matching "${search_text}"', mapping=dict(search_text=self.search_text))

        replacements = dict(context=self.context.displayname, search_text=self.search_text)
        # Check if the set of selected status has a special title.
        status_set_title = self.status_title_map.get(frozenset(self.status_filter))
        if status_set_title:
            replacements["status"] = status_set_title
            if self.search_text:
                return _('${status} questions matching "${search_text}" ' "for ${context}", mapping=replacements)
            else:
                return _("${status} questions for ${context}", mapping=replacements)
        else:
            if self.search_text:
                return _('Questions matching "${search_text}" for ' "${context}", mapping=replacements)
            else:
                return _("Questions for ${context}", mapping=replacements)
示例#5
0
    IQuestionCollection,
    IQuestionSet,
    ISearchableByQuestionOwner,
    )
from lp.answers.interfaces.questionmessage import IQuestionMessage
from lp.answers.interfaces.questionsperson import IQuestionsPerson
from lp.answers.interfaces.questionsubscription import IQuestionSubscription
from lp.answers.interfaces.questiontarget import IQuestionTarget
from lp.services.webservice.apihelpers import (
    patch_collection_return_type,
    patch_entry_return_type,
    patch_reference_property,
    )


IQuestionSet.queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['collection_entry_schema'] = IQuestion
patch_entry_return_type(IQuestionSet, 'get', IQuestion)
patch_collection_return_type(
    IQuestionTarget, 'findSimilarQuestions', IQuestion)
patch_collection_return_type(
    IQuestionCollection, 'searchQuestions', IQuestion)
patch_collection_return_type(
    ISearchableByQuestionOwner, 'searchQuestions', IQuestion)
patch_reference_property(IQuestionMessage, 'question', IQuestion)
patch_reference_property(IQuestionSubscription, 'question', IQuestion)
patch_collection_return_type(
    IQuestionsPerson, 'getDirectAnswerQuestionTargets', IQuestionTarget)
patch_collection_return_type(
    IQuestionsPerson, 'getTeamAnswerQuestionTargets', IQuestionTarget)
patch_collection_return_type(
    IQuestionsPerson, 'searchQuestions', IQuestion)
from lp.answers.interfaces.questioncollection import (
    IQuestionSet,
    ISearchableByQuestionOwner,
    )
from lp.answers.interfaces.questionmessage import IQuestionMessage
from lp.answers.interfaces.questionsperson import IQuestionsPerson
from lp.answers.interfaces.questionsubscription import IQuestionSubscription
from lp.answers.interfaces.questiontarget import IQuestionTarget
from lp.services.webservice.apihelpers import (
    patch_collection_return_type,
    patch_entry_return_type,
    patch_reference_property,
    )


IQuestionSet.queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['collection_entry_schema'] = IQuestion
patch_entry_return_type(IQuestionSet, 'get', IQuestion)
patch_collection_return_type(
    IQuestionTarget, 'findSimilarQuestions', IQuestion)
patch_collection_return_type(
    ISearchableByQuestionOwner, 'searchQuestions', IQuestion)
patch_reference_property(IQuestionMessage, 'question', IQuestion)
patch_reference_property(IQuestionSubscription, 'question', IQuestion)
patch_collection_return_type(
    IQuestionsPerson, 'getDirectAnswerQuestionTargets', IQuestionTarget)
patch_collection_return_type(
    IQuestionsPerson, 'getTeamAnswerQuestionTargets', IQuestionTarget)
patch_collection_return_type(
    IQuestionsPerson, 'searchQuestions', IQuestion)