|
6 | 6 | Only Studio-specfic helper functions should be added here. |
7 | 7 | Platform-wide Python APIs should be added to an appropriate api.py file instead. |
8 | 8 | """ |
| 9 | + |
9 | 10 | from __future__ import annotations |
10 | 11 |
|
11 | 12 | import json |
|
33 | 34 | from cms.djangoapps.models.settings.course_grading import CourseGradingModel |
34 | 35 | from cms.lib.xblock.upstream_sync import UpstreamLink, UpstreamLinkException |
35 | 36 | from cms.lib.xblock.upstream_sync_block import fetch_customizable_fields_from_block |
| 37 | +from openedx.core.djangoapps.content_staging.api import StagedContentID |
36 | 38 | from openedx.core.djangoapps.content_staging.data import LIBRARY_SYNC_PURPOSE |
37 | 39 | from openedx.core.djangoapps.content_tagging.types import TagValuesByObjectIdDict |
38 | 40 | from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers |
39 | 41 | from openedx.core.djangoapps.video_config.transcripts_utils import Transcript, build_components_import_path |
| 42 | +from openedx.core.types import AuthUser as UserType |
40 | 43 | from xmodule.contentstore.content import StaticContent |
41 | 44 | from xmodule.contentstore.django import contentstore |
42 | 45 | from xmodule.exceptions import NotFoundError |
@@ -280,7 +283,10 @@ def create_usage(self, def_id) -> UsageKey: |
280 | 283 | def create_definition(self, block_type, slug=None) -> DefinitionLocator: |
281 | 284 | """ Generate a new definition_id for an XBlock """ |
282 | 285 | # Note: Split modulestore will detect this temporary ID and create a new definition ID when the XBlock is saved. |
283 | | - return DefinitionLocator(block_type, LocalId(block_type)) |
| 286 | + # FIXME: The DefinitionLocator technically only accepts an ObjectId (or a str representing an ObjectId), but |
| 287 | + # this code relies on passing a LocalId and having it save the LocalId object as its `definition_id`. We should |
| 288 | + # either change this in the future or update DefinitionLocator to support LocalId-typed definition IDs. |
| 289 | + return DefinitionLocator(block_type, LocalId(block_type)) # type: ignore[arg-type] |
284 | 290 |
|
285 | 291 |
|
286 | 292 | @frozen |
@@ -312,7 +318,7 @@ def _rewrite_static_asset_references(downstream_xblock: XBlock, substitutions: d |
312 | 318 |
|
313 | 319 |
|
314 | 320 | def _insert_static_files_into_downstream_xblock( |
315 | | - downstream_xblock: XBlock, staged_content_id: int, request |
| 321 | + downstream_xblock: XBlock, staged_content_id: StagedContentID, request |
316 | 322 | ) -> StaticFileNotices: |
317 | 323 | """ |
318 | 324 | Gets static files from staged content, and inserts them into the downstream XBlock. |
@@ -452,7 +458,7 @@ def _fetch_and_set_upstream_link( |
452 | 458 | copied_from_block: str, |
453 | 459 | copied_from_version_num: int, |
454 | 460 | temp_xblock: XBlock, |
455 | | - user: User |
| 461 | + user: UserType, |
456 | 462 | ): |
457 | 463 | """ |
458 | 464 | Fetch and set upstream link for the given xblock which is being pasted. This function handles following cases: |
@@ -513,7 +519,7 @@ def _import_xml_node_to_parent( |
513 | 519 | # The modulestore we're using |
514 | 520 | store, |
515 | 521 | # The user who is performing this operation |
516 | | - user: User, |
| 522 | + user: UserType, |
517 | 523 | # Hint to use as usage ID (block_id) for the new XBlock |
518 | 524 | slug_hint: str | None = None, |
519 | 525 | # Content tags applied to the source XBlock(s) |
@@ -635,7 +641,7 @@ def _import_xml_node_to_parent( |
635 | 641 |
|
636 | 642 | def _import_files_into_course( |
637 | 643 | course_key: CourseKey, |
638 | | - staged_content_id: int, |
| 644 | + staged_content_id: StagedContentID, |
639 | 645 | static_files: list[content_staging_api.StagedContentFileData], |
640 | 646 | usage_key: UsageKey, |
641 | 647 | ) -> tuple[StaticFileNotices, dict[str, str]]: |
@@ -700,7 +706,7 @@ def _import_files_into_course( |
700 | 706 |
|
701 | 707 | def _import_file_into_course( |
702 | 708 | course_key: CourseKey, |
703 | | - staged_content_id: int, |
| 709 | + staged_content_id: StagedContentID, |
704 | 710 | file_data_obj: content_staging_api.StagedContentFileData, |
705 | 711 | usage_key: UsageKey, |
706 | 712 | ) -> tuple[bool | None, dict]: |
@@ -760,7 +766,7 @@ def _import_file_into_course( |
760 | 766 |
|
761 | 767 | def _import_transcripts( |
762 | 768 | block: XBlock, |
763 | | - staged_content_id: int, |
| 769 | + staged_content_id: StagedContentID, |
764 | 770 | static_files: list[content_staging_api.StagedContentFileData], |
765 | 771 | ): |
766 | 772 | """ |
|
0 commit comments