Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f305d06
feat: implement sketch of models and API for containers
mariajgrimaldi Oct 25, 2024
fd601c6
feat: Implement higher-level APIs for getting components from units
bradenmacdonald Feb 13, 2025
15bad53
feat: Expand tests cases, add more high-level APIs
bradenmacdonald Feb 14, 2025
6586bd4
refactor: consolidate defined_list/initial_list/frozen_list into enti…
bradenmacdonald Feb 21, 2025
5f202e9
test: expand test cases
bradenmacdonald Feb 21, 2025
d3f2174
feat: get_containers_with_entity() API to find containers using a com…
bradenmacdonald Feb 25, 2025
4fda3cb
refactor: remove redundant 'entity' arg
bradenmacdonald Feb 26, 2025
dbbcedb
feat: allow changing container title/metadata without changing its list
bradenmacdonald Feb 26, 2025
8719a70
test: add test for deleting unit without affecting components within
bradenmacdonald Feb 26, 2025
ee3f845
refactor: ContainerEntity -> Container, ContainerEntityVersion -> Con…
bradenmacdonald Mar 1, 2025
3afb5b3
docs: update docstring of Container class
bradenmacdonald Mar 3, 2025
62d6d1b
fix: address review comments
bradenmacdonald Mar 5, 2025
c8f10ed
fix: preloading with get_unit() was too minimal
bradenmacdonald Mar 5, 2025
84f658d
test: update test_units_containing to catch bad JOINs in the query
bradenmacdonald Mar 5, 2025
411d8ac
chore: update with main branch
bradenmacdonald Mar 7, 2025
580b1f6
refactor: move 'containers' models into publishing
bradenmacdonald Mar 7, 2025
e753971
feat: auto-publish children when publishing a container
bradenmacdonald Mar 5, 2025
f666ba4
feat: allow specifying components when creating a unit
bradenmacdonald Mar 11, 2025
4972f43
refactor: Units inherit Containers (Multi-Table Inheritance)
bradenmacdonald Mar 12, 2025
84f3b5d
fix: minor cleanups
bradenmacdonald Mar 12, 2025
2f04aca
feat: consolidate get_enitities_in_[published|draft]_container APIs
bradenmacdonald Mar 12, 2025
1ae08af
refactor: consolidate some repetition
bradenmacdonald Mar 12, 2025
466b44b
refactor: move model_mixins back where it was
bradenmacdonald Mar 12, 2025
e6334fb
fix: ensure order_num is unique on each entity list row
bradenmacdonald Mar 12, 2025
dcb0a1b
refactor: move mixins to publishable_entity.py to avoid circular imports
ormsbee Mar 12, 2025
ceaca78
docs: address review - minor clarifications and renames
bradenmacdonald Mar 13, 2025
7945315
feat: change get_components_in_unit() to raise if no published version
bradenmacdonald Mar 13, 2025
07a9385
chore: version bump to 0.19.0
bradenmacdonald Mar 14, 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.18.3"
__version__ = "0.19.0"
1 change: 1 addition & 0 deletions openedx_learning/api/authoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ..apps.authoring.components.api import *
from ..apps.authoring.contents.api import *
from ..apps.authoring.publishing.api import *
from ..apps.authoring.units.api import *

# This was renamed after the authoring API refactoring pushed this and other
# app APIs into the openedx_learning.api.authoring module. Here I'm aliasing to
Expand Down
2 changes: 1 addition & 1 deletion openedx_learning/api/authoring_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
from ..apps.authoring.collections.models import *
from ..apps.authoring.components.models import *
from ..apps.authoring.contents.models import *
from ..apps.authoring.publishing.model_mixins import *
from ..apps.authoring.publishing.models import *
from ..apps.authoring.units.models import *
4 changes: 2 additions & 2 deletions openedx_learning/apps/authoring/components/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def create_next_component_version(
return component_version


def create_component_and_version(
def create_component_and_version( # pylint: disable=too-many-positional-arguments
learning_package_id: int,
/,
component_type: ComponentType,
Expand Down Expand Up @@ -326,7 +326,7 @@ def component_exists_by_key(
return False


def get_components(
def get_components( # pylint: disable=too-many-positional-arguments
learning_package_id: int,
/,
draft: bool | None = None,
Expand Down
19 changes: 7 additions & 12 deletions openedx_learning/apps/authoring/components/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
"""
from __future__ import annotations

from typing import ClassVar

from django.db import models

from ....lib.fields import case_sensitive_char_field, immutable_uuid_field, key_field
from ....lib.managers import WithRelationsManager
from ..contents.models import Content
from ..publishing.model_mixins import PublishableEntityMixin, PublishableEntityVersionMixin
from ..publishing.models import LearningPackage
from ..publishing.models import LearningPackage, PublishableEntityMixin, PublishableEntityVersionMixin

__all__ = [
"ComponentType",
Expand Down Expand Up @@ -76,7 +77,7 @@ def __str__(self) -> str:
return f"{self.namespace}:{self.name}"


class Component(PublishableEntityMixin): # type: ignore[django-manager-missing]
class Component(PublishableEntityMixin):
"""
This represents any Component that has ever existed in a LearningPackage.

Expand Down Expand Up @@ -120,14 +121,12 @@ class Component(PublishableEntityMixin): # type: ignore[django-manager-missing]
Make a foreign key to the Component model when you need a stable reference
that will exist for as long as the LearningPackage itself exists.
"""
# Tell mypy what type our objects manager has.
# It's actually PublishableEntityMixinManager, but that has the exact same
# interface as the base manager class.
objects: models.Manager[Component] = WithRelationsManager(
# Set up our custom manager. It has the same API as the default one, but selects related objects by default.
objects: ClassVar[WithRelationsManager[Component]] = WithRelationsManager( # type: ignore[assignment]
'component_type'
)

with_publishing_relations: models.Manager[Component] = WithRelationsManager(
with_publishing_relations = WithRelationsManager(
'component_type',
'publishable_entity',
'publishable_entity__draft__version',
Expand Down Expand Up @@ -201,10 +200,6 @@ class ComponentVersion(PublishableEntityVersionMixin):
This holds the content using a M:M relationship with Content via
ComponentVersionContent.
"""
# Tell mypy what type our objects manager has.
# It's actually PublishableEntityVersionMixinManager, but that has the exact
# same interface as the base manager class.
objects: models.Manager[ComponentVersion]

# This is technically redundant, since we can get this through
# publishable_entity_version.publishable.component, but this is more
Expand Down
Loading