diff --git a/cms/djangoapps/contentstore/config/waffle.py b/cms/djangoapps/contentstore/config/waffle.py index f86154053c..d5707c9eae 100644 --- a/cms/djangoapps/contentstore/config/waffle.py +++ b/cms/djangoapps/contentstore/config/waffle.py @@ -9,6 +9,7 @@ WAFFLE_NAMESPACE = u'studio' # Switches ENABLE_ACCESSIBILITY_POLICY_PAGE = u'enable_policy_page' +ENABLE_CHECKLISTS_PAGE = u'enable_checklists_page' def waffle(): @@ -31,3 +32,9 @@ ENABLE_IN_CONTEXT_IMAGE_SELECTION = CourseWaffleFlag( flag_name=u'enable_in_context_image_selection', flag_undefined_default=False ) + +ENABLE_CHECKLISTS_QUALITY = CourseWaffleFlag( + waffle_namespace=waffle_flags(), + flag_name=u'enable_checklists_quality', + flag_undefined_default=False +) diff --git a/cms/djangoapps/contentstore/config/waffle_utils.py b/cms/djangoapps/contentstore/config/waffle_utils.py new file mode 100644 index 0000000000..33d2959dc7 --- /dev/null +++ b/cms/djangoapps/contentstore/config/waffle_utils.py @@ -0,0 +1,30 @@ +"""Util methods for Waffle checks""" + +from cms.djangoapps.contentstore.config.waffle import waffle, ENABLE_CHECKLISTS_PAGE, ENABLE_CHECKLISTS_QUALITY +from student.roles import GlobalStaff + + +def should_show_checklists_page(requesting_user): + """ + Determine if the ENABLE_CHECKLISTS_PAGE waffle switch is set + and if the user is able to see it + """ + + if waffle().is_enabled(ENABLE_CHECKLISTS_PAGE): + if GlobalStaff().has_user(requesting_user): + return True + + return False + + +def should_show_checklists_quality(requesting_user, course_key): + """ + Determine if the ENABLE_CHECKLISTS_QUALITY waffle flag is set + and if the user is able to see it + """ + + if ENABLE_CHECKLISTS_QUALITY.is_enabled(course_key): + if GlobalStaff().has_user(requesting_user): + return True + + return False diff --git a/cms/djangoapps/contentstore/views/__init__.py b/cms/djangoapps/contentstore/views/__init__.py index 0242ac5723..e90628aef4 100644 --- a/cms/djangoapps/contentstore/views/__init__.py +++ b/cms/djangoapps/contentstore/views/__init__.py @@ -7,6 +7,7 @@ from .assets import * from .component import * from .course import * +from .checklists import * from .entrance_exam import * from .error import * from .helpers import * diff --git a/cms/djangoapps/contentstore/views/checklists.py b/cms/djangoapps/contentstore/views/checklists.py new file mode 100644 index 0000000000..f3fb7cffba --- /dev/null +++ b/cms/djangoapps/contentstore/views/checklists.py @@ -0,0 +1,33 @@ +# pylint: disable=missing-docstring +from django.contrib.auth.decorators import login_required +from django.core.exceptions import PermissionDenied +from django.views.decorators.csrf import ensure_csrf_cookie +from opaque_keys.edx.keys import CourseKey +from xmodule.modulestore.django import modulestore + +from edxmako.shortcuts import render_to_response +from student.auth import has_course_author_access + +__all__ = ['checklists_handler'] + + +@login_required +@ensure_csrf_cookie +def checklists_handler(request, course_key_string=None): + ''' + The restful handler for course checklists. + It allows retrieval of the checklists (as an HTML page). + + GET + html: return an html page which will show course checklists. Note that only the checklists container + is returned and that the actual data is determined with a client-side request. + ''' + course_key = CourseKey.from_string(course_key_string) + if not has_course_author_access(request.user, course_key): + raise PermissionDenied() + + course_module = modulestore().get_course(course_key) + return render_to_response('checklists.html', { + 'language_code': request.LANGUAGE_CODE, + 'context_course': course_module, + }) diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 6e7833f992..1e8cef3022 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -637,6 +637,7 @@ def course_index(request, course_key): deprecated_blocks_info = _deprecated_blocks_info(course_module, deprecated_block_names) return render_to_response('course_outline.html', { + 'language_code': request.LANGUAGE_CODE, 'context_course': course_module, 'lms_link': lms_link, 'sections': sections, diff --git a/cms/static/sass/views/_outline.scss b/cms/static/sass/views/_outline.scss index ac06a835b9..1a996c04bf 100644 --- a/cms/static/sass/views/_outline.scss +++ b/cms/static/sass/views/_outline.scss @@ -185,12 +185,13 @@ .status-release, .status-pacing, - .status-highlights-enabled { + .status-highlights-enabled, + .status-checklist { @extend %t-copy-base; display: inline-block; color: $color-copy-base; - margin-right: $baseline; + margin-right: ($baseline/2); // STATE: hover &:hover { diff --git a/cms/templates/checklists.html b/cms/templates/checklists.html new file mode 100644 index 0000000000..af36cc6e31 --- /dev/null +++ b/cms/templates/checklists.html @@ -0,0 +1,55 @@ +<%page expression_filter="h"/> +<%inherit file="base.html" /> +<%def name="online_help_token()"><% return "files" %>%def> +<%! + from cms.djangoapps.contentstore.config.waffle_utils import should_show_checklists_quality + from django.core.urlresolvers import reverse + from django.utils.translation import ugettext as _ + from openedx.core.djangolib.markup import HTML, Text + from openedx.core.djangolib.js_utils import js_escaped_string, dump_js_escaped_json +%> +<%block name="title">${_("Checklists")}%block> +<%block name="bodyclass">is-signedin course uploads view-uploads%block> + +<%namespace name='static' file='static_content.html'/> + +<%block name="header_extras"> + +%block> + +<%block name="content"> + +
${course_release_date}
-