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

Version 0.14.3
--------------

- Remove some styling for topic box names so they wrap, adjusting icons (#1328)
- Lock file maintenance (#1262)
- fix flaky tests (#1324)
- urlencode search_filter (#1326)
- Moves all env vars to global APP_SETTINGS (#1310)
- Remap topic icons according to what's in the topics listing (#1322)
- Fix podcast duration frontend display (#1321)
- Update topics code for PWT topic mappings (#1275)
- Convert durations to ISO8601 format (podcast episodes) (#1317)
- No prices for archived runs or resources w/out certificates (#1305)

Version 0.14.2 (Released July 25, 2024)
--------------

Expand Down
11 changes: 8 additions & 3 deletions channels/plugins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Plugins for channels"""

from urllib.parse import urlencode

from django.apps import apps
from django.utils.text import slugify

Expand Down Expand Up @@ -34,7 +36,10 @@ def topic_upserted(self, topic, overwrite):
channel, _ = Channel.objects.update_or_create(
name=slugify(topic.name),
channel_type=ChannelType.topic.name,
defaults={"title": topic.name, "search_filter": f"topic={topic.name}"},
defaults={
"title": topic.name,
"search_filter": urlencode({"topic": topic.name}),
},
)
ChannelTopicDetail.objects.update_or_create(channel=channel, topic=topic)
return channel, True
Expand Down Expand Up @@ -73,7 +78,7 @@ def department_upserted(self, department, overwrite):
channel = None
elif department.school and (overwrite or not channel):
channel, _ = Channel.objects.update_or_create(
search_filter=f"department={department.department_id}",
search_filter=urlencode({"department": department.department_id}),
channel_type=ChannelType.department.name,
defaults={
"name": slugify(department.name),
Expand Down Expand Up @@ -117,7 +122,7 @@ def offeror_upserted(self, offeror, overwrite):
channel_type=ChannelType.unit.name,
defaults={
"title": offeror.name,
"search_filter": f"offered_by={offeror.code}",
"search_filter": urlencode({"offered_by": offeror.code}),
},
)
ChannelUnitDetail.objects.update_or_create(channel=channel, unit=offeror)
Expand Down
4 changes: 2 additions & 2 deletions channels/plugins_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
@pytest.mark.parametrize("overwrite", [True, False])
def test_search_index_plugin_topic_upserted(overwrite):
"""The plugin function should create a topic channel"""
topic = LearningResourceTopicFactory.create()
topic = LearningResourceTopicFactory.create(name="Test & Testing Topic")
channel, created = ChannelPlugin().topic_upserted(topic, overwrite)
assert created is True
assert channel.topic_detail.topic == topic
assert channel.title == topic.name
assert channel.channel_type == ChannelType.topic.name
assert channel.search_filter == f"topic={topic.name}"
assert channel.search_filter == "topic=Test+%26+Testing+Topic"
same_channel, upserted = ChannelPlugin().topic_upserted(topic, overwrite)
assert channel == same_channel
assert upserted is overwrite
Expand Down
40 changes: 40 additions & 0 deletions data_fixtures/migrations/0004_upsert_initial_topic_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.2.14 on 2024-07-18 19:57

from django.db import migrations

from learning_resources.utils import upsert_topic_data_file


def perform_topic_upsert(apps, schema_editor):
"""
Upsert the topic data from the default location.

This clears existing topics before upserting, and clears topic channels.
After this migration runs, you will need to repopulate these things.
"""

LearningResourceTopic = apps.get_model(
"learning_resources", "LearningResourceTopic"
)
Channel = apps.get_model("channels", "Channel")

LearningResourceTopic.objects.all().delete()
Channel.objects.filter(channel_type="topic").delete()

upsert_topic_data_file()


def perform_topic_unupsert(apps, schema_editor):
"""Do nothing (this is just to make the migration reversable)."""


class Migration(migrations.Migration):
"""Insert the topic data from the topics.yaml file."""

dependencies = [
("data_fixtures", "0003_unit_page_copy_updates"),
]

operations = [
migrations.RunPython(perform_topic_upsert, perform_topic_unupsert),
]
Loading