Skip to content

Commit f111bf6

Browse files
ChrisChVpomegranitedrpenido
authored
feat: return unit upstreamInfo and disallow edits to units in courses that are sourced from a library (#773)
* feat: Add upstream_info to unit * feat: disallow edits to units in courses that are sourced from a library (#774) --------- Co-authored-by: Jillian Vogel <jill@opencraft.com> Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>
1 parent 45e9a34 commit f111bf6

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

cms/djangoapps/contentstore/views/preview.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,14 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
299299
if selected_groups_label:
300300
selected_groups_label = _('Access restricted to: {list_of_groups}').format(list_of_groups=selected_groups_label) # lint-amnesty, pylint: disable=line-too-long
301301
course = modulestore().get_course(xblock.location.course_key)
302-
can_edit = context.get('can_edit', True)
303-
can_add = context.get('can_add', True)
302+
303+
if root_xblock and root_xblock.upstream and str(root_xblock.upstream).startswith('lct:'):
304+
can_edit = False
305+
can_add = False
306+
else:
307+
can_edit = context.get('can_edit', True)
308+
can_add = context.get('can_add', True)
309+
304310
# Is this a course or a library?
305311
is_course = xblock.context_key.is_course
306312
tags_count_map = context.get('tags_count_map')
@@ -315,7 +321,7 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
315321
'is_root': is_root,
316322
'is_reorderable': is_reorderable,
317323
'can_edit': can_edit,
318-
'can_edit_visibility': context.get('can_edit_visibility', is_course),
324+
'can_edit_visibility': can_edit and context.get('can_edit_visibility', is_course),
319325
'course_authoring_url': settings.COURSE_AUTHORING_MICROFRONTEND_URL,
320326
'is_loading': context.get('is_loading', False),
321327
'is_selected': context.get('is_selected', False),

cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,10 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
12781278
if is_xblock_unit:
12791279
# if xblock is a Unit we add the discussion_enabled option
12801280
xblock_info["discussion_enabled"] = xblock.discussion_enabled
1281+
1282+
# Also add upstream info
1283+
xblock_info["upstream_info"] = UpstreamLink.try_get_for_block(xblock).to_json()
1284+
12811285
if xblock.category == "sequential":
12821286
# Entrance exam subsection should be hidden. in_entrance_exam is
12831287
# inherited metadata, all children will have it.

cms/templates/studio_xblock_wrapper.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,13 @@
211211
<span data-tooltip="${_('Drag to reorder')}" class="drag-handle action"></span>
212212
</li>
213213
% endif
214-
% elif not show_inline:
215-
<li class="action-item action-edit action-edit-view-only">
216-
<a href="#" class="edit-button action-button">
217-
<span class="action-button-text">${_("Details")}</span>
218-
</a>
219-
</li>
214+
% if not show_inline:
215+
<li class="action-item action-edit action-edit-view-only">
216+
<a href="#" class="edit-button action-button">
217+
<span class="action-button-text">${_("Details")}</span>
218+
</a>
219+
</li>
220+
% endif
220221
% endif
221222
% endif
222223
</ul>

0 commit comments

Comments
 (0)