110 |
110 |
111 @property |
111 @property |
112 def values(self): |
112 def values(self): |
113 intids = get_utility(IIntIds) |
113 intids = get_utility(IIntIds) |
114 catalog = get_utility(ICatalog) |
114 catalog = get_utility(ICatalog) |
115 params = Eq(catalog['parents'], intids.register(self.context)) & \ |
|
116 Any(catalog['content_type'], CONTENT_TYPES.keys()) |
|
117 query = self.request.params.get('query') |
115 query = self.request.params.get('query') |
118 if query: |
116 if query: |
119 sequence = get_utility(ISequentialIntIds) |
117 sequence = get_utility(ISequentialIntIds) |
120 query = query.lower() |
118 query = query.lower() |
121 if query.startswith('+'): |
119 if query.startswith('+'): |
122 params &= Eq(catalog['oid'], sequence.get_full_oid(query)) |
120 params = Eq(catalog['oid'], sequence.get_full_oid(query)) |
123 else: |
121 else: |
|
122 params = Eq(catalog['parents'], intids.register(self.context)) & \ |
|
123 Any(catalog['content_type'], CONTENT_TYPES.keys()) |
124 query_params = Eq(catalog['oid'], sequence.get_full_oid(query)) |
124 query_params = Eq(catalog['oid'], sequence.get_full_oid(query)) |
125 negotiator = get_utility(INegotiator) |
125 negotiator = get_utility(INegotiator) |
126 for lang in {self.request.registry.settings.get('pyramid.default_locale_name', 'en'), |
126 for lang in {self.request.registry.settings.get('pyramid.default_locale_name', 'en'), |
127 self.request.locale_name, |
127 self.request.locale_name, |
128 negotiator.server_language} | negotiator.offered_languages: |
128 negotiator.server_language} | negotiator.offered_languages: |
130 if index_name in catalog: |
130 if index_name in catalog: |
131 index = catalog[index_name] |
131 index = catalog[index_name] |
132 if index.check_query(query): |
132 if index.check_query(query): |
133 query_params |= Contains(index, ' and '.join((w+'*' for w in query.split()))) |
133 query_params |= Contains(index, ' and '.join((w+'*' for w in query.split()))) |
134 params &= query_params |
134 params &= query_params |
135 return unique(map(get_last_version, |
135 return unique(map(get_last_version, |
136 CatalogResultSet(CatalogQuery(catalog).query(params, |
136 CatalogResultSet(CatalogQuery(catalog).query(params, |
137 sort_index='modified_date', |
137 sort_index='modified_date', |
138 reverse=True)))) |
138 reverse=True)))) |
|
139 else: |
|
140 return () |
139 |
141 |
140 |
142 |
141 # |
143 # |
142 # Advanced search views |
144 # Advanced search views |
143 # |
145 # |