Skip to content
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
9 changes: 5 additions & 4 deletions contentcuration/kolibri_public/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from django.contrib.postgres.aggregates import BitOr
from django.core.cache import cache
from django.db.models import Case
from django.db.models import F
from django.db.models import Max
from django.db.models import Value
from django.db.models import When
Expand Down Expand Up @@ -63,10 +64,10 @@ def _get_available_languages(base_queryset):
from contentcuration.models import Language

langs = Language.objects.filter(
id__in=base_queryset.exclude(lang=None)
.values_list("lang_id", flat=True)
.distinct()
).values("id", "lang_name")
id__in=base_queryset.exclude(lang=None).values_list("lang_id", flat=True).distinct()
# Updated to use contentcuration field names
# Convert language objects to dicts mapped to the kolibri field names
).values("id", lang_name=F("native_name"))
return list(langs)


Expand Down
9 changes: 9 additions & 0 deletions contentcuration/kolibri_public/tests/test_content_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from rest_framework.test import APITestCase

from contentcuration.models import generate_storage_url
from contentcuration.models import Language


kind_activity_map = {
Expand Down Expand Up @@ -186,6 +187,14 @@ def test_contentnode_list(self):
self.assertEqual(len(response.data), expected_output)
self._assert_nodes(response.data, nodes)

def test_contentnode_list_labels(self):
nodes = self.root.get_descendants(include_self=True).filter(available=True)
response = self._get(reverse("publiccontentnode-list"), data={"max_results": 1})
node_languages = Language.objects.filter(contentnode__in=nodes)
self.assertEqual(len(response.data["labels"]["languages"]), node_languages.distinct().count())
for lang in response.data["labels"]["languages"]:
self.assertTrue(node_languages.filter(native_name=lang["lang_name"]).exists())

def test_contentnode_list_headers(self):
channel = models.ChannelMetadata.objects.get()
channel.last_updated = datetime.datetime.now()
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pytest-pythonpath
pytest-timeout
pytest-watch
pre-commit==1.15.1
codecov
coverage
pytest-cov
nodeenv
Expand Down
4 changes: 0 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ click==8.1.3
# -c requirements.txt
# flask
# pip-tools
codecov==2.1.12
# via -r requirements-dev.in
colorama==0.4.4
# via pytest-watch
configargparse==1.5.3
Expand All @@ -50,7 +48,6 @@ coreschema==0.0.4
coverage[toml]==6.2
# via
# -r requirements-dev.in
# codecov
# pytest-cov
customizable-django-profiler @ git+https://github.com/someshchaturvedi/customizable-django-profiler.git
# via -r requirements-dev.in
Expand Down Expand Up @@ -220,7 +217,6 @@ pyzmq==23.1.0
requests==2.25.1
# via
# -c requirements.txt
# codecov
# coreapi
# locust
roundrobin==0.0.2
Expand Down