Skip to content
This repository was archived by the owner on Jan 28, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions importer/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,10 @@ def get_counts():
).distinct()
self.assertEqual(htmls.count(), 1)
self.assertEqual(
[asset.asset for asset in htmls[0].static_assets.all()],
[
sorted([
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes belong to commit #377; hopefully it'll be merged before this one.

asset.asset.name for asset in htmls[0].static_assets.all()]),
sorted([
"assets/edX/toy/TT_2012_Fall/essays_x250.png",
"assets/edX/toy/TT_2012_Fall/webGLDemo.css",
]
])
)
7 changes: 5 additions & 2 deletions search/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ def prepare(self, obj):
"""
prepared = super(LearningResourceIndex, self).prepare(obj)
for vocab in Vocabulary.objects.all():
# Values with spaces do not work, so we use the slug.
# Values with spaces do not work, so replace them with underscores.
# Slugify doesn't work because it adds hypens, which are also
# split by Elasticsearch.
terms = [
term.label for term in obj.terms.filter(vocabulary_id=vocab.id)
term.label.replace(" ", "_")
for term in obj.terms.filter(vocabulary_id=vocab.id)
]
prepared[vocab.slug] = terms
# for faceted "_exact" in URL
Expand Down
3 changes: 2 additions & 1 deletion search/tests/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Tests for search engine indexing."""

from learningresources.tests.base import LoreTestCase
Expand All @@ -20,7 +21,7 @@ def setUp(self):
Term.objects.create(
vocabulary_id=self.vocabulary.id, label=label, weight=1
)
for label in ("easy", "medium", "difficult")
for label in ("easy", "medium", "very difficult", "ancòra")
]

def count_results(self, query):
Expand Down
12 changes: 12 additions & 0 deletions search/tests/test_search_view.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Tests for repostitory listing view search."""

from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -28,3 +29,14 @@ def test_single_repo(self):
)
resp = self.client.get(reverse("repositories", args=(new_repo.slug,)))
self.assertNotContains(resp, self.resource.title)

def test_terms_with_spaces(self):
"""
Terms with spaces should show up in facet list correctly.
"""
for term in self.terms:
self.resource.terms.add(term)
resp = self.client.get(reverse("repositories", args=(self.repo.slug,)))
self.assertContains(resp, "easy")
self.assertContains(resp, "ancòra")
self.assertContains(resp, "very difficult")
2 changes: 1 addition & 1 deletion ui/templates/includes/facet_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h4 class="panel-title">
data-facet-name="{{ name|urlencode }}_exact"
data-facet-value="{{ term.0 }}"
>
<label for="check-{{ name }}-{{ forloop.counter }}">{{ term.0 }}</label>
<label for="check-{{ name }}-{{ forloop.counter }}">{{ term.2 }}</label>
<span class="badge">{{ term.1 }}</span>
</li>
{% endfor %}
Expand Down
4 changes: 3 additions & 1 deletion ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ def extra_context(self):
context.update({
"repo": self.repo,
"perms_on_cur_repo": get_perms(self.request.user, self.repo),
# Add a non-slug version to the context for display. This
# turns a "two-tuple" into a "three-tuple."
"vocabularies": {
k: v
k: [x + (x[0].replace("_", " "),) for x in v]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you trying to reconstruct the therm here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaces ("slug", "count") with ("slug", "count", "pretty name").

For example, ("very_difficult", "3") would become ("very_difficult", "3", "very difficult").

for k, v in context["facets"]["fields"].items()
if k in vocabularies
},
Expand Down