111111 sever_upstream_link ,
112112 sync_from_upstream ,
113113)
114+ from cms .lib .xblock .container_upstream_sync import *
114115from common .djangoapps .student .auth import has_studio_read_access , has_studio_write_access
115116from openedx .core .lib .api .view_utils import (
116117 DeveloperErrorViewMixin ,
@@ -310,11 +311,21 @@ def post(self, request: _AuthenticatedRequest, usage_key_string: str) -> Respons
310311 """
311312 downstream = _load_accessible_block (request .user , usage_key_string , require_write_access = True )
312313 try :
313- if downstream .usage_key .block_type == "video" :
314- # Delete all transcripts so we can copy new ones from upstream
315- clear_transcripts (downstream )
316- upstream = sync_from_upstream (downstream , request .user )
317- static_file_notices = import_static_assets_for_library_sync (downstream , upstream , request )
314+ if downstream .usage_key .block_type == "vertical" :
315+ UpstreamLinkClass = ContainerUpstreamLink
316+ upstream = sync_from_upstream_container (downstream , request .user )
317+
318+ # TODO support static assets on containers
319+ static_file_notices = None
320+ else :
321+ if downstream .usage_key .block_type == "video" :
322+ # Delete all transcripts so we can copy new ones from upstream
323+ clear_transcripts (downstream )
324+
325+ UpstreamLinkClass = UpstreamLink
326+ upstream = sync_from_upstream (downstream , request .user )
327+
328+ static_file_notices = import_static_assets_for_library_sync (downstream , upstream , request )
318329 except UpstreamLinkException as exc :
319330 logger .exception (
320331 "Could not sync from upstream '%s' to downstream '%s'" ,
@@ -323,10 +334,15 @@ def post(self, request: _AuthenticatedRequest, usage_key_string: str) -> Respons
323334 )
324335 raise ValidationError (detail = str (exc )) from exc
325336 modulestore ().update_item (downstream , request .user .id )
326- # Note: We call `get_for_block` (rather than `try_get_for_block`) because if anything is wrong with the
337+
338+ # Note: We call `get_for_*` (rather than `try_get_for_*`) because if anything is wrong with the
327339 # upstream at this point, then that is completely unexpected, so it's appropriate to let the 500 happen.
328- response = UpstreamLink .get_for_block (downstream ).to_json ()
329- response ["static_file_notices" ] = attrs_asdict (static_file_notices )
340+ if downstream .usage_key .block_type == "vertical" :
341+ response = ContainerUpstreamLink .get_for_container (downstream ).to_json ()
342+ else :
343+ response = UpstreamLinkClass .get_for_block (downstream ).to_json ()
344+ response ["static_file_notices" ] = attrs_asdict (static_file_notices )
345+
330346 return Response (response )
331347
332348 def delete (self , request : _AuthenticatedRequest , usage_key_string : str ) -> Response :
@@ -335,7 +351,10 @@ def delete(self, request: _AuthenticatedRequest, usage_key_string: str) -> Respo
335351 """
336352 downstream = _load_accessible_block (request .user , usage_key_string , require_write_access = True )
337353 try :
338- decline_sync (downstream )
354+ if downstream .usage_key .block_type == "vertical" :
355+ decline_sync_container (downstream )
356+ else :
357+ decline_sync (downstream )
339358 except (NoUpstream , BadUpstream , BadDownstream ) as exc :
340359 # This is somewhat unexpected. If the upstream link is missing or invalid, then the downstream author
341360 # shouldn't have been prompted to accept/decline a sync in the first place. Of course, they could have just
0 commit comments