42
54
language=None, sort=None):
43
55
"""Return the questions from the collection matching search criteria.
45
:search_text: A string that is matched against the question
46
title and description. If None, the search_text is not included as
49
:status: A sequence of QuestionStatus Items. If None or an empty
50
sequence, the status is not included as a filter criteria.
52
:language: An ILanguage or a sequence of ILanguage objects to match
53
against the question's language. If None or an empty sequence,
54
the language is not included as a filter criteria.
56
:sort: An attribute of QuestionSort. If None, a default value is used.
57
When there is a search_text value, the default is to sort by
58
RELEVANCY, otherwise results are sorted NEWEST_FIRST.
57
:param search_text: A string that is matched against the question
58
title and description. If None, the search_text is not included as
61
:param status: A sequence of QuestionStatus Items. If None or an empty
62
sequence, the status is not included as a filter criteria.
64
:param language: An ILanguage or a sequence of ILanguage objects to
65
match against the question's language. If None or an empty
66
sequence, the language is not included as a filter criteria.
68
:param sort: An attribute of QuestionSort. If None, a default value is
69
used. When there is a search_text value, the default is to sort by
70
RELEVANCY, otherwise results are sorted NEWEST_FIRST.
61
73
def getQuestionLanguages():
66
78
class ISearchableByQuestionOwner(IQuestionCollection):
67
79
"""Collection that support searching by question owner."""
81
@operation_parameters(
83
title=_('Search text'), required=False),
85
title=_('Status'), required=False,
86
value_type=Choice(vocabulary=QuestionStatus)),
88
title=_('Language'), required=False,
89
value_type=ReferenceChoice(vocabulary='Language')),
90
owner=PublicPersonChoice(
91
title=_('Owner'), required=False,
92
vocabulary='ValidPerson'),
93
needs_attention_from=PublicPersonChoice(
94
title=_('Needs attentions from'), required=False,
95
vocabulary='ValidPerson'),
97
title=_('Sort'), required=False,
98
vocabulary=QuestionSort))
99
@operation_returns_collection_of(Interface) # IQuestion.
100
@export_read_operation()
101
@operation_for_version('devel')
69
102
def searchQuestions(search_text=None,
70
status=QUESTION_STATUS_DEFAULT_SEARCH,
103
# Lp wants a sequence, but lazr.restful only supports
104
# lists; cast the tuple as a list.
105
status=list(QUESTION_STATUS_DEFAULT_SEARCH),
71
106
language=None, sort=None, owner=None,
72
107
needs_attention_from=None):
73
108
"""Return the questions from the collection matching search criteria.
75
See `IQuestionCollection` for the description of the standard search
78
:owner: The IPerson that created the question.
80
:needs_attention_from: Selects questions that nee attention from an
81
IPerson. These are the questions in the NEEDSINFO or ANSWERED state
82
owned by the person. The questions not owned by the person but on
83
which the person requested more information or gave an answer
84
and that are back in the OPEN state are also included.
110
:param search_text: A string that is matched against the question
111
title and description. If None, the search_text is not included as
113
:param status: A sequence of QuestionStatus Items. If None or an empty
114
sequence, the status is not included as a filter criteria. The
115
default is to match all status except Expired and Invalid.
116
:param language: An ILanguage or a sequence of ILanguage objects to
117
match against the question's language. If None or an empty
118
sequence, the language is not included as a filter criteria.
119
:param owner: The IPerson that created the question.
120
:param needs_attention_from: Selects questions that need attention
121
from an IPerson. These are the questions in the NEEDSINFO or
122
ANSWERED state owned by the person. The questions not owned by the
123
person but on which the person requested more information or gave
124
an answer and that are back in the OPEN state are also included.
125
:param sort: An attribute of QuestionSort. If None, a default value is
126
used. When there is a search_text value, the default is to sort by
127
RELEVANCY, otherwise results are sorted NEWEST_FIRST.