From aa42751c7ef0e2a245efdc562934df3b6216ec3e Mon Sep 17 00:00:00 2001
From: "Dave St.Germain"
Date: Fri, 7 Feb 2020 12:42:18 -0500
Subject: [PATCH] Add button to switch to courseware MFE
---
lms/djangoapps/courseware/views/index.py | 2 +-
lms/templates/preview_menu.html | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py
index 938c7d1dc8..4a0fcdd719 100644
--- a/lms/djangoapps/courseware/views/index.py
+++ b/lms/djangoapps/courseware/views/index.py
@@ -482,7 +482,7 @@ class CoursewareIndex(View):
table_of_contents['previous_of_active_section'],
table_of_contents['next_of_active_section'],
)
-
+ courseware_context['unit'] = section_context.get('activate_block_id', '')
courseware_context['fragment'] = self.section.render(self.view, section_context)
if self.section.position and self.section.has_children:
diff --git a/lms/templates/preview_menu.html b/lms/templates/preview_menu.html
index 7b239d78d8..44e0d546a9 100644
--- a/lms/templates/preview_menu.html
+++ b/lms/templates/preview_menu.html
@@ -19,6 +19,16 @@ show_preview_menu = course and can_masquerade and supports_preview_menu
def selected(is_selected):
return "selected" if is_selected else ""
+ def get_mfe_link():
+ if section:
+ mfe_link = '{}course/{}/{}'.format(settings.LEARNING_MICROFRONTEND_URL, course.id, section.location)
+ if unit:
+ mfe_link += '/' + unit
+ else:
+ mfe_link = None
+ return mfe_link
+
+ mfe_link = get_mfe_link()
course_partitions = get_all_partitions_for_course(course)
masquerade_user_name = masquerade.user_name if masquerade else None
masquerade_group_id = masquerade.group_id if masquerade else None
@@ -66,6 +76,12 @@ show_preview_menu = course and can_masquerade and supports_preview_menu
% endif
+ % if user.is_staff and mfe_link:
+
+ % endif