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
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Unreleased
**********

* Add support for Typesense as the search backend.
* Fix: Set default value for ``pinned`` field on ``CommentThread`` to ``False``
to prevent NULL sort bug.

0.3.4 – 2025-08-13
******************
Expand Down
2 changes: 1 addition & 1 deletion forum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Openedx forum app.
"""

__version__ = "0.4.0"
__version__ = "0.4.1"
1 change: 1 addition & 0 deletions forum/backends/mysql/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,7 @@ def create_thread(data: dict[str, Any]) -> str:
thread_type=data.get("thread_type", "discussion"),
context=data.get("context", "course"),
last_activity_at=timezone.now(),
pinned=data.get("pinned", False),
**optional_args,
)
return str(new_thread.pk)
Expand Down
2 changes: 1 addition & 1 deletion forum/backends/mysql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class CommentThread(Content):
)
closed: models.BooleanField[bool, bool] = models.BooleanField(default=False)
pinned: models.BooleanField[Optional[bool], bool] = models.BooleanField(
null=True, blank=True
default=False
)
last_activity_at: models.DateTimeField[Optional[datetime], datetime] = (
models.DateTimeField(null=True, blank=True)
Expand Down
2 changes: 1 addition & 1 deletion forum/migration_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def create_or_update_thread(thread_data: dict[str, Any]) -> None:
anonymous=thread_data.get("anonymous", False),
anonymous_to_peers=thread_data.get("anonymous_to_peers", False),
closed=thread_data.get("closed", False),
pinned=thread_data.get("pinned"),
pinned=thread_data.get("pinned", False),
last_activity_at=make_aware(thread_data["last_activity_at"]),
commentable_id=thread_data.get("commentable_id"),
)
Expand Down
26 changes: 26 additions & 0 deletions forum/migrations/0005_alter_commentthread_pinned.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 5.2.12 on 2026-03-27 06:58

from typing import Any

from django.db import migrations, models


def backfill_pinned_false(apps: Any, schema_editor: Any) -> None:
CommentThread = apps.get_model("forum", "CommentThread")
CommentThread.objects.filter(pinned__isnull=True).update(pinned=False)


class Migration(migrations.Migration):

dependencies = [
("forum", "0004_add_author_username_fields"),
]

operations = [
migrations.RunPython(backfill_pinned_false, migrations.RunPython.noop),
migrations.AlterField(
model_name="commentthread",
name="pinned",
field=models.BooleanField(default=False),
),
]
2 changes: 1 addition & 1 deletion tests/test_backends/test_mysql/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_comment_thread_creation() -> None:
assert comment_thread.thread_type == "discussion"
assert comment_thread.context == "course"
assert comment_thread.closed is False
assert comment_thread.pinned is None
assert comment_thread.pinned is False


@pytest.mark.django_db
Expand Down
Loading