diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 70686f0353..d49ae2f6c7 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -467,7 +467,10 @@ def course_listing(request): List all courses available to the logged in user """ courses, in_process_course_actions = get_courses_accessible_to_user(request) - libraries = _accessible_libraries_list(request.user) if LIBRARIES_ENABLED else [] + user = request.user + user_has_permission =\ + user.is_active and (user.is_staff or CourseCreatorRole().has_user(user)) + libraries = _accessible_libraries_list(request.user) if LIBRARIES_ENABLED and user_has_permission else [] programs_config = ProgramsApiConfig.current() raw_programs = get_programs(request.user) if programs_config.is_studio_tab_enabled else [] @@ -516,18 +519,18 @@ def course_listing(request): return render_to_response('index.html', { 'courses': courses, 'in_process_course_actions': in_process_course_actions, - 'libraries_enabled': LIBRARIES_ENABLED, - 'libraries': [format_library_for_view(lib) for lib in libraries], - 'show_new_library_button': LIBRARIES_ENABLED and request.user.is_active, 'user': request.user, 'request_course_creator_url': reverse('contentstore.views.request_course_creator'), 'course_creator_status': _get_course_creator_status(request.user), 'rerun_creator_status': GlobalStaff().has_user(request.user), 'allow_unicode_course_id': settings.FEATURES.get('ALLOW_UNICODE_COURSE_ID', False), 'allow_course_reruns': settings.FEATURES.get('ALLOW_COURSE_RERUNS', True), + 'libraries_enabled': LIBRARIES_ENABLED, + 'libraries': [format_library_for_view(lib) for lib in libraries], + 'library_creator_status': _get_library_creator_status(user), 'is_programs_enabled': programs_config.is_studio_tab_enabled and request.user.is_staff, 'programs': programs, - 'program_authoring_url': reverse('programs'), + 'program_authoring_url': reverse('programs') }) @@ -1646,3 +1649,25 @@ def _get_course_creator_status(user): course_creator_status = 'granted' return course_creator_status + + +def _get_library_creator_status(user): + """ + Helper method for returning the library creation status for a particular user, + taking into account the values of DISABLE_LIBRARY_CREATION and LIBRARIES_ENABLED. + """ + if user.is_staff: + library_creator_status = 'granted' + elif settings.FEATURES.get('DISABLE_LIBRARY_CREATION', False): + library_creator_status = 'disallowed_for_this_site' + elif settings.FEATURES.get('ENABLE_CREATOR_GROUP', False): + library_creator_status = get_course_creator_status(user) + if library_creator_status is None: + # User not grandfathered in as an existing user, has not previously visited the dashboard page. + # Add the user to the course creator admin table with status 'unrequested'. + add_user_with_status_unrequested(user) + library_creator_status = get_course_creator_status(user) + else: + library_creator_status = 'granted' + + return library_creator_status diff --git a/cms/envs/common.py b/cms/envs/common.py index 11c0842b8d..3c94ee9ed1 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -168,6 +168,7 @@ FEATURES = { # Enable support for content libraries. Note that content libraries are # only supported in courses using split mongo. 'ENABLE_CONTENT_LIBRARIES': True, + 'DISABLE_LIBRARY_CREATION': False, # Milestones application flag 'MILESTONES_APP': False, diff --git a/cms/templates/index.html b/cms/templates/index.html index daf518d8a6..ad652dd5e3 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -34,7 +34,7 @@ from openedx.core.djangolib.markup import HTML, Text ${_("Email staff to create course")} % endif - % if show_new_library_button: + % if library_creator_status=='granted': ${_("New Library")} % endif @@ -130,7 +130,7 @@ from openedx.core.djangolib.markup import HTML, Text % endif - %if libraries_enabled and show_new_library_button: + %if libraries_enabled and library_creator_status=='granted':
@@ -497,7 +497,7 @@ from openedx.core.djangolib.markup import HTML, Text
- % if show_new_library_button: + % if library_creator_status=='granted':

${_('Create Your First Library')}