Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ComponentType model #147

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c23f373
feat: add features to support v2 libraries
ormsbee Jan 8, 2024
18d3cf8
test: add more test coverage for components API
ormsbee Jan 24, 2024
75f7a2e
test: more test coverage
ormsbee Jan 24, 2024
58661a5
refactor: adjust indentation
ormsbee Jan 27, 2024
75d1dfa
feat: add deletion support to create_next_version and document it better
ormsbee Jan 27, 2024
8a7a294
test: add more type annotations
ormsbee Jan 27, 2024
19ed2ad
fix: improve comments and fix annotation error
ormsbee Jan 27, 2024
9f47e36
fix; differentiate draft and published title search
ormsbee Jan 27, 2024
3639c14
fix: linter error on missing test docstring
ormsbee Jan 27, 2024
3270d2d
fix: correct annotations
ormsbee Jan 27, 2024
cbb8a93
fix: remove unnecessary import
ormsbee Jan 27, 2024
69b8874
refactor: soft delete changes, comments, test names
ormsbee Jan 29, 2024
66c7a67
test: test reset-to-published functionality
ormsbee Jan 29, 2024
9f57f60
feat: add get_published_version
ormsbee Jan 29, 2024
f62f8c5
tests: test LearningPackage modification
ormsbee Jan 29, 2024
e810163
chore: linter fixes
ormsbee Jan 29, 2024
5cf43d2
chore: linter fixes
ormsbee Jan 29, 2024
2b13a25
chore: more linter fixes
ormsbee Jan 29, 2024
c39b3ab
chore: fix import order for migrations
ormsbee Jan 30, 2024
cc2df99
test: add annotation for what kind of queryset
ormsbee Jan 30, 2024
d36ec08
refactor: punt the id vs. pk question by making it positional-only
ormsbee Jan 30, 2024
9695377
docs: better comments
ormsbee Jan 30, 2024
0704913
refactor: normalize component types with ComponentType
ormsbee Jan 31, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ venv/

# Media files (for uploads)
media/

# Media files generated during test runs
test_media/
16 changes: 8 additions & 8 deletions olx_importer/management/commands/load_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
has really happened between what's currently stored/published for a particular
item and the new value we want to set? For RawContent that's easy, because we
have actual hashes of the data. But it's not clear how that would work for
something like an ComponentVersion. We'd have to have some kind of mechanism where every
something like an ComponentVersion. We'd have to have some kind of mechanism where every
pp that wants to attach data gets to answer the question of "has anything
changed?" in order to decide if we really make a new ComponentVersion or not.
"""
Expand All @@ -35,7 +35,7 @@
SUPPORTED_TYPES = ["problem", "video", "html"]
logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Load sample Component data from course export"

Expand Down Expand Up @@ -95,7 +95,7 @@ def load_course_data(self, learning_package_key):
self.import_block_type(block_type, now) #, publish_log_entry)

publishing_api.publish_all_drafts(
self.learning_package.id,
self.learning_package.id,
message="Initial Import from load_components script"
)

Expand All @@ -117,7 +117,7 @@ def create_content(self, static_local_path, now, component_version):
return # Might as well bail if we can't find the file.

raw_content, _created = contents_api.get_or_create_raw_content(
learning_package_id=self.learning_package.id,
self.learning_package.id,
data_bytes=data_bytes,
mime_type=mime_type,
created=now,
Expand Down Expand Up @@ -153,12 +153,12 @@ def import_block_type(self, block_type, now): # , publish_log_entry):
logger.error(f"Parse error for {xml_file_path}: {err}")
components_skipped += 1
continue

display_name = block_root.attrib.get("display_name", "")
_component, component_version = components_api.create_component_and_version(
learning_package_id=self.learning_package.id,
self.learning_package.id,
namespace=namespace,
type=block_type,
type_name=block_type,
local_key=local_key,
title=display_name,
created=now,
Expand All @@ -168,7 +168,7 @@ def import_block_type(self, block_type, now): # , publish_log_entry):
# Create the RawContent entry for the raw data...
data_bytes = xml_file_path.read_bytes()
text_content, _created = contents_api.get_or_create_text_content_from_bytes(
learning_package_id=self.learning_package.id,
self.learning_package.id,
data_bytes=data_bytes,
mime_type=f"application/vnd.openedx.xblock.v1.{block_type}+xml",
created=now,
Expand Down
2 changes: 1 addition & 1 deletion openedx_learning/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
Open edX Learning ("Learning Core").
"""
__version__ = "0.4.4"
__version__ = "0.5.0"
7 changes: 3 additions & 4 deletions openedx_learning/core/components/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ class ComponentAdmin(ReadOnlyModelAdmin):
"""
Django admin configuration for Component
"""
list_display = ("key", "uuid", "namespace", "type", "created")
list_display = ("key", "uuid", "component_type", "created")
readonly_fields = [
"learning_package",
"uuid",
"namespace",
"type",
"component_type",
"key",
"created",
]
list_filter = ("type", "learning_package")
list_filter = ("component_type", "learning_package")
search_fields = ["publishable_entity__uuid", "publishable_entity__key"]
inlines = [ComponentVersionInline]

Expand Down
Loading
Loading