Commit 00a42fe1 by jagonzalr

show button new library in studio depending on flags and user staff status

parent 6c37e282
...@@ -467,7 +467,7 @@ def course_listing(request): ...@@ -467,7 +467,7 @@ def course_listing(request):
List all courses available to the logged in user List all courses available to the logged in user
""" """
courses, in_process_course_actions = get_courses_accessible_to_user(request) courses, in_process_course_actions = get_courses_accessible_to_user(request)
libraries = _accessible_libraries_list(request.user) if LIBRARIES_ENABLED else [] libraries = _accessible_libraries_list(request.user) if LIBRARIES_ENABLED and request.user.is_staff else []
programs_config = ProgramsApiConfig.current() programs_config = ProgramsApiConfig.current()
raw_programs = get_programs(request.user) if programs_config.is_studio_tab_enabled else [] raw_programs = get_programs(request.user) if programs_config.is_studio_tab_enabled else []
...@@ -518,7 +518,7 @@ def course_listing(request): ...@@ -518,7 +518,7 @@ def course_listing(request):
'in_process_course_actions': in_process_course_actions, 'in_process_course_actions': in_process_course_actions,
'libraries_enabled': LIBRARIES_ENABLED, 'libraries_enabled': LIBRARIES_ENABLED,
'libraries': [format_library_for_view(lib) for lib in libraries], 'libraries': [format_library_for_view(lib) for lib in libraries],
'show_new_library_button': LIBRARIES_ENABLED and request.user.is_active, 'show_new_library_button': _get_library_creation_status(request.user),
'user': request.user, 'user': request.user,
'request_course_creator_url': reverse('contentstore.views.request_course_creator'), 'request_course_creator_url': reverse('contentstore.views.request_course_creator'),
'course_creator_status': _get_course_creator_status(request.user), 'course_creator_status': _get_course_creator_status(request.user),
...@@ -1631,6 +1631,7 @@ def _get_course_creator_status(user): ...@@ -1631,6 +1631,7 @@ def _get_course_creator_status(user):
If the user passed in has not previously visited the index page, it will be If the user passed in has not previously visited the index page, it will be
added with status 'unrequested' if the course creator group is in use. added with status 'unrequested' if the course creator group is in use.
""" """
if user.is_staff: if user.is_staff:
course_creator_status = 'granted' course_creator_status = 'granted'
elif settings.FEATURES.get('DISABLE_COURSE_CREATION', False): elif settings.FEATURES.get('DISABLE_COURSE_CREATION', False):
...@@ -1646,3 +1647,22 @@ def _get_course_creator_status(user): ...@@ -1646,3 +1647,22 @@ def _get_course_creator_status(user):
course_creator_status = 'granted' course_creator_status = 'granted'
return course_creator_status return course_creator_status
def _get_library_creation_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 LIBRARIES_ENABLED:
if user.is_active and user.is_staff:
if not settings.FEATURES.get('DISABLE_LIBRARY_CREATION', False):
return True
else:
return False
else:
return False
else:
return False
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