Merge pull request #8015 from edx/andya/add-tab-extensions
Add extensible course view types for edX platform
This commit is contained in:
@@ -6,7 +6,11 @@ from mock import patch
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test.client import RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from courseware.tabs import get_course_tab_list
|
||||
from courseware.tests.factories import UserFactory
|
||||
from courseware.tests.helpers import LoginEnrollmentTestCase
|
||||
|
||||
from student.tests.factories import AdminFactory, UserFactory
|
||||
@@ -56,6 +60,21 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
return 'Demographic data is now available in <a href="http://example.com/courses/{}" ' \
|
||||
'target="_blank">Example</a>.'.format(unicode(self.course.id))
|
||||
|
||||
def test_instructor_tab(self):
|
||||
"""
|
||||
Verify that the instructor tab appears for staff only.
|
||||
"""
|
||||
def has_instructor_tab(user, course):
|
||||
"""Returns true if the "Instructor" tab is shown."""
|
||||
request = RequestFactory().request()
|
||||
request.user = user
|
||||
tabs = get_course_tab_list(request, course)
|
||||
return len([tab for tab in tabs if tab.name == 'Instructor']) == 1
|
||||
|
||||
self.assertTrue(has_instructor_tab(self.instructor, self.course))
|
||||
student = UserFactory.create()
|
||||
self.assertFalse(has_instructor_tab(student, self.course))
|
||||
|
||||
def test_default_currency_in_the_html_response(self):
|
||||
"""
|
||||
Test that checks the default currency_symbol ($) in the response
|
||||
|
||||
@@ -38,15 +38,33 @@ from course_modes.models import CourseMode, CourseModesArchive
|
||||
from student.roles import CourseFinanceAdminRole, CourseSalesAdminRole
|
||||
from certificates.models import CertificateGenerationConfiguration
|
||||
from certificates import api as certs_api
|
||||
from openedx.core.djangoapps.course_views.course_views import CourseViewType
|
||||
|
||||
from class_dashboard.dashboard_data import get_section_display_name, get_array_section_has_problem
|
||||
from .tools import get_units_with_due_date, title_or_url, bulk_email_is_enabled_for_course
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class InstructorDashboardViewType(CourseViewType):
|
||||
"""
|
||||
Defines the Instructor Dashboard view type that is shown as a course tab.
|
||||
"""
|
||||
|
||||
name = "instructor"
|
||||
title = _('Instructor')
|
||||
view_name = "instructor_dashboard"
|
||||
is_dynamic = True # The "Instructor" tab is instead dynamically added when it is enabled
|
||||
|
||||
@classmethod
|
||||
def is_enabled(cls, course, user=None): # pylint: disable=unused-argument,redefined-outer-name
|
||||
"""
|
||||
Returns true if the specified user has staff access.
|
||||
"""
|
||||
return user and has_access(user, 'staff', course, course.id)
|
||||
|
||||
|
||||
@ensure_csrf_cookie
|
||||
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
|
||||
def instructor_dashboard_2(request, course_id):
|
||||
|
||||
Reference in New Issue
Block a user