Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c90c97a
feat: grouped draft changes (DraftChangeLog)
ormsbee Feb 27, 2025
361e27c
test: add container/child draft change log tests
ormsbee Apr 1, 2025
c01a3a4
test: draft side effect tests and behavior writeup
ormsbee Apr 1, 2025
80c8847
test: placeholder so I don't forget to write this test
ormsbee Apr 1, 2025
3646370
feat: add migration to infer DraftChangeLogs from existing data.
ormsbee Apr 1, 2025
2ef81cc
fix: admin needed to be updated after naming refactor
ormsbee Apr 1, 2025
e7e9cc3
temp: tried to clean up the DraftChange docstring to be more helpful
ormsbee Apr 1, 2025
17192da
temp: incorporate review feedback
ormsbee Apr 2, 2025
6cc7dc2
temp: assorted pylint/mypy fixups, because my brain isn't working wel…
ormsbee Apr 2, 2025
7e5b928
docs: rewrite docstring for DraftChangeLog to be more comprehensive
ormsbee Apr 2, 2025
5023ebd
temp: be more specific in notation
ormsbee Apr 2, 2025
554b265
test: fix mypy errors
ormsbee Apr 3, 2025
7f558aa
test: more linting fixes
ormsbee Apr 3, 2025
f6d6192
chore: import sorting
ormsbee Apr 3, 2025
3aa8360
fix: handle edge case around resetting to previous draft versions, ad…
ormsbee Apr 4, 2025
6c895ef
temp: minor comment fixes
ormsbee Apr 4, 2025
141a4fb
test: add tests
ormsbee Apr 9, 2025
3b8a273
temp: linter fixups
ormsbee Apr 9, 2025
fce7154
temp: add more type annotations
ormsbee Apr 9, 2025
951afb6
fix: broken test was passing in entity version ID isntead of entity ID
ormsbee Apr 9, 2025
643758d
refactor: update for rebase-introduced migration and API change
ormsbee Apr 11, 2025
7b65c81
refactor: no, really, changing the migrations now
ormsbee Apr 11, 2025
7063f5d
chore: no_pii annotations on draft models
ormsbee Apr 11, 2025
26cbd1e
fix: enrich type annotation of exit_callbacks
kdmccormick Apr 15, 2025
a4edf0d
docs: get_containers_with_entity TODO followup link
kdmccormick Apr 16, 2025
b0f911a
refactor: simplify active_change_log conditional
kdmccormick Apr 16, 2025
c7aa0a2
docs: rm outdated comment
kdmccormick Apr 16, 2025
bbc4dc2
docs: document bulk_draft_changes_for
kdmccormick Apr 16, 2025
36642ea
build: increment version, 0.22 -> 0.23
kdmccormick Apr 16, 2025
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: 1 addition & 1 deletion openedx_learning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Open edX Learning ("Learning Core").
"""

__version__ = "0.22.0"
__version__ = "0.23.0"
77 changes: 76 additions & 1 deletion openedx_learning/apps/authoring/publishing/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@
from __future__ import annotations

from django.contrib import admin
from django.db.models import Count

from openedx_learning.lib.admin_utils import ReadOnlyModelAdmin, one_to_one_related_model_html

from .models import LearningPackage, PublishableEntity, Published, PublishLog, PublishLogRecord
from .models import (
DraftChangeLog,
DraftChangeLogRecord,
LearningPackage,
PublishableEntity,
PublishLog,
PublishLogRecord,
)
from .models.publish_log import Published


@admin.register(LearningPackage)
Expand Down Expand Up @@ -171,3 +180,69 @@ def published_at(self, published_obj):

def message(self, published_obj):
return published_obj.publish_log_record.publish_log.message


class DraftChangeLogRecordTabularInline(admin.TabularInline):
"""
Tabular inline for a single Draft change.
"""
model = DraftChangeLogRecord

fields = (
"entity",
"title",
"old_version_num",
"new_version_num",
)
readonly_fields = fields

def get_queryset(self, request):
queryset = super().get_queryset(request)
return queryset.select_related("entity", "old_version", "new_version") \
.order_by("entity__key")

def old_version_num(self, draft_change: DraftChangeLogRecord):
if draft_change.old_version is None:
return "-"
return draft_change.old_version.version_num

def new_version_num(self, draft_change: DraftChangeLogRecord):
if draft_change.new_version is None:
return "-"
return draft_change.new_version.version_num

def title(self, draft_change: DraftChangeLogRecord):
"""
Get the title to display for the DraftChange
"""
if draft_change.new_version:
return draft_change.new_version.title
if draft_change.old_version:
return draft_change.old_version.title
return ""


@admin.register(DraftChangeLog)
class DraftChangeSetAdmin(ReadOnlyModelAdmin):
"""
Read-only admin to view Draft changes (via inline tables)
"""
inlines = [DraftChangeLogRecordTabularInline]
fields = (
"uuid",
"learning_package",
"num_changes",
"changed_at",
"changed_by",
)
readonly_fields = fields
list_display = fields
list_filter = ["learning_package"]

def num_changes(self, draft_change_set):
return draft_change_set.num_changes

def get_queryset(self, request):
queryset = super().get_queryset(request)
return queryset.select_related("learning_package", "changed_by") \
.annotate(num_changes=Count("records"))
Loading