Commit ab49631b by jagonzalr Committed by renevatium

add disable library creation feature flag

parent b8bc4c87
......@@ -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
......@@ -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,
......
......@@ -34,7 +34,7 @@ from openedx.core.djangolib.markup import HTML, Text
<a href="mailto:${settings.FEATURES.get('STUDIO_REQUEST_EMAIL','')}">${_("Email staff to create course")}</a>
% endif
% if show_new_library_button:
% if library_creator_status=='granted':
<a href="#" class="button new-button new-library-button"><span class="icon fa fa-plus icon-inline" aria-hidden="true"></span>
${_("New Library")}</a>
% 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':
<div class="wrapper-create-element wrapper-create-library">
<form class="form-create create-library library-info" id="create-library-form" name="create-library-form">
<div class="wrap-error">
......@@ -497,7 +497,7 @@ from openedx.core.djangolib.markup import HTML, Text
</div>
</div>
</div>
% if show_new_library_button:
% if library_creator_status=='granted':
<div class="notice-item has-actions">
<div class="msg">
<h3 class="title">${_('Create Your First Library')}</h3>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment