Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bug 685111] Search assumes tags inherit.

Update the Sphinx config so it pulls tags off the *parent* document,
if it exists, so that translations inherit their parents' tags.
  • Loading branch information...
commit 65fde520defd6b70d1b712fc9d794d4d872f0c0c 1 parent 3ff58fe
James Socol authored
Showing with 21 additions and 4 deletions.
  1. +12 −0 apps/search/tests/test_search.py
  2. +9 −4 configs/sphinx/sphinx.conf
View
12 apps/search/tests/test_search.py
@@ -310,6 +310,12 @@ def test_tags(self):
response = self.client.get(reverse('search'), qs)
eq_(total, json.loads(response.content)['total'])
+ def test_tags_inherit(self):
+ """Translations inherit tags from their parents."""
+ qs = {'a': 1, 'w': 1, 'format': 'json', 'tags': 'extant'}
+ response = self.client.get(reverse('search', locale='es'), qs)
+ eq_(1, json.loads(response.content)['total'])
+
def test_products(self):
"""Search for products."""
qs = {'a': 1, 'w': 1, 'format': 'json'}
@@ -325,6 +331,12 @@ def test_products(self):
response = self.client.get(reverse('search'), qs)
eq_(total, json.loads(response.content)['total'])
+ def test_products_inherit(self):
+ """Translations inherit products from their parents."""
+ qs = {'a': 1, 'w': 1, 'format': 'json', 'product': 'desktop'}
+ response = self.client.get(reverse('search', locale='fr'), qs)
+ eq_(1, json.loads(response.content)['total'])
+
def test_unicode_excerpt(self):
"""Unicode characters in the excerpt should not be a problem."""
wc = WikiClient()
View
13 configs/sphinx/sphinx.conf
@@ -290,13 +290,18 @@ source wiki_pages
sql_attr_bool = is_archived
sql_attr_multi = uint tag from query; SELECT \
- d.id, \
+ d1.id, \
CRC32(t.name) \
- FROM \
- wiki_document d \
+ FROM ( \
+ SELECT \
+ d.id AS id, \
+ IF(d.parent_id, d.parent_id, d.id) AS joiner \
+ FROM \
+ wiki_document d \
+ ) d1 \
INNER JOIN \
taggit_taggeditem ti \
- ON d.id = ti.object_id AND \
+ ON joiner = ti.object_id AND \
ti.content_type_id = (\
SELECT \
id \
Please sign in to comment.
Something went wrong with that request. Please try again.