Skip to content
Closed
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
6 changes: 6 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
=============

Version 0.22.2
--------------

- search facet accessibility fixes (#1698)
- exclude topics with no associated channel from Topic querySets (#1693)

Version 0.22.1 (Released October 15, 2024)
--------------

Expand Down
2 changes: 1 addition & 1 deletion frontends/mit-learn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"dependencies": {
"@ebay/nice-modal-react": "^1.2.13",
"@mitodl/course-search-utils": "^3.1.6",
"@mitodl/course-search-utils": "^3.2.5",
"@remixicon/react": "^4.2.0",
"@sentry/react": "^7.57.0",
"@tanstack/react-query": "^4.36.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const FacetStyles = styled.div`
margin-bottom: 14px;

i {
color: ${({ theme }) => theme.custom.colors.silverGrayLight};
color: ${({ theme }) => theme.custom.colors.silverGrayDark};
}

&:hover i {
Expand Down Expand Up @@ -216,6 +216,16 @@ const FacetStyles = styled.div`
}
}

.facets:not(.facets-expanded, .facets-transitioning):has(
button.filter-section-button
) {
div.facet-visible,
div.facet-list,
div.input-wrapper {
visibility: hidden;
}
}

.filterable-facet {
.facet-list {
max-height: 400px;
Expand Down
4 changes: 4 additions & 0 deletions learning_resources/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ class TopicViewSet(viewsets.ReadOnlyModelViewSet):
filter_backends = [DjangoFilterBackend]
filterset_class = TopicFilter

def filter_queryset(self, queryset):
queryset = queryset.exclude(channel_url__isnull=True)
return super().filter_queryset(queryset)

@method_decorator(
cache_page_for_all_users(
settings.SEARCH_PAGE_CACHE_DURATION, cache="redis", key_prefix="search"
Expand Down
17 changes: 9 additions & 8 deletions learning_resources/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ def test_topics_list_endpoint(client, django_assert_num_queries):
LearningResourceTopicFactory.create_batch(100),
key=lambda topic: topic.name,
)
for topic in topics:
ChannelTopicDetailFactory.create(topic=topic)

with django_assert_num_queries(2):
resp = client.get(reverse("lr:v1:topics_api-list"))
Expand All @@ -564,28 +566,27 @@ def test_topics_list_endpoint(client, django_assert_num_queries):
def test_topics_detail_endpoint(client):
"""Test topics detail endpoint"""
topic = LearningResourceTopicFactory.create()
ChannelTopicDetailFactory.create(topic=topic)
resp = client.get(reverse("lr:v1:topics_api-detail", args=[topic.pk]))
assert resp.data == LearningResourceTopicSerializer(instance=topic).data


@pytest.mark.parametrize("published", [True, False])
def test_topic_channel_url(client, published):
"""
Check that the topic API returns 'None' for channel_url of unpublished channels.

Note: The channel_url being None is also tested on the Channel model itself,
but the API may generate the channel_url in a slightly different manner (for
example, queryset annotation)
Test that topics with published channels return the channel_url,
and unpublished channels are not included in the response
"""
topic = LearningResourceTopicFactory.create()
channel = ChannelTopicDetailFactory.create(
topic=topic, is_unpublished=not published
).channel
resp = client.get(reverse("lr:v1:topics_api-detail", args=[topic.pk]))

assert resp.data["channel_url"] == channel.channel_url
if not published:
assert resp.data["channel_url"] is None
if published:
assert resp.data["channel_url"] == channel.channel_url
else:
assert resp.status_code == 404


def test_departments_list_endpoint(client):
Expand Down
2 changes: 1 addition & 1 deletion main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from main.settings_pluggy import * # noqa: F403
from openapi.settings_spectacular import open_spectacular_settings

VERSION = "0.22.1"
VERSION = "0.22.2"

log = logging.getLogger()

Expand Down
Loading
Loading