do not show FBE upsell to full access users
This commit is contained in:
committed by
Matthew Piatetsky
parent
7144b8ec63
commit
96844c1d05
@@ -82,7 +82,8 @@ class ContentTypeGatingPartition(UserPartition):
|
||||
course_key = self._get_course_key_from_course_block(block)
|
||||
modes = CourseMode.modes_for_course_dict(course_key)
|
||||
verified_mode = modes.get(CourseMode.VERIFIED)
|
||||
if verified_mode is None or not self._is_audit_enrollment(user, block):
|
||||
if (verified_mode is None or not self._is_audit_enrollment(user, course_key) or
|
||||
user_group == FULL_ACCESS):
|
||||
return None
|
||||
ecommerce_checkout_link = self._get_checkout_link(user, verified_mode.sku)
|
||||
|
||||
@@ -95,17 +96,19 @@ class ContentTypeGatingPartition(UserPartition):
|
||||
return frag
|
||||
|
||||
def access_denied_message(self, block, user, user_group, allowed_groups):
|
||||
if self._is_audit_enrollment(user, block):
|
||||
return _(u"Graded assessments are available to Verified Track learners. Upgrade to Unlock.")
|
||||
return None
|
||||
course_key = self._get_course_key_from_course_block(block)
|
||||
modes = CourseMode.modes_for_course_dict(course_key)
|
||||
verified_mode = modes.get(CourseMode.VERIFIED)
|
||||
if (verified_mode is None or not self._is_audit_enrollment(user, course_key) or
|
||||
user_group == FULL_ACCESS):
|
||||
return None
|
||||
return _(u"Graded assessments are available to Verified Track learners. Upgrade to Unlock.")
|
||||
|
||||
def _is_audit_enrollment(self, user, block):
|
||||
def _is_audit_enrollment(self, user, course_key):
|
||||
"""
|
||||
Checks if user is enrolled in `Audit` track of course or any staff member is
|
||||
viewing course as in `Audit` enrollment.
|
||||
"""
|
||||
course_key = self._get_course_key_from_course_block(block)
|
||||
|
||||
if self._is_masquerading_as_generic_student(user, course_key):
|
||||
return self._is_masquerading_audit_enrollment(user, course_key)
|
||||
return self._has_active_enrollment_in_audit_mode(user, course_key)
|
||||
|
||||
@@ -8,12 +8,13 @@ from course_modes.tests.factories import CourseModeFactory
|
||||
from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
|
||||
from openedx.features.content_type_gating.helpers import CONTENT_GATING_PARTITION_ID
|
||||
from openedx.features.content_type_gating.helpers import CONTENT_GATING_PARTITION_ID, FULL_ACCESS
|
||||
from openedx.features.content_type_gating.partitions import (
|
||||
create_content_gating_partition,
|
||||
ContentTypeGatingPartition
|
||||
)
|
||||
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
|
||||
from student.tests.factories import GroupFactory
|
||||
from xmodule.partitions.partitions import UserPartitionError, ENROLLMENT_TRACK_PARTITION_ID
|
||||
|
||||
|
||||
@@ -93,10 +94,34 @@ class TestContentTypeGatingPartition(CacheIsolationTestCase):
|
||||
'crum.get_current_request',
|
||||
return_value=mock_request
|
||||
):
|
||||
fragment = partition.access_denied_fragment(mock_block, global_staff, 'test_group', 'test_allowed_group')
|
||||
fragment = partition.access_denied_fragment(mock_block, global_staff, GroupFactory(), 'test_allowed_group')
|
||||
|
||||
self.assertIsNotNone(fragment)
|
||||
|
||||
def test_access_denied_fragment_for_full_access_users(self):
|
||||
"""
|
||||
Test that Full Access users do not see the access_denied_fragment or access_denied_message
|
||||
"""
|
||||
mock_request = RequestFactory().get('/')
|
||||
mock_course = Mock(id=self.course_key, user_partitions={})
|
||||
mock_block = Mock(scope_ids=Mock(usage_id=Mock(course_key=mock_course.id)))
|
||||
|
||||
CourseModeFactory.create(course_id=mock_course.id, mode_slug='verified')
|
||||
|
||||
global_staff = GlobalStaffFactory.create()
|
||||
ContentTypeGatingConfig.objects.create(enabled=False, studio_override_enabled=True)
|
||||
|
||||
partition = create_content_gating_partition(mock_course)
|
||||
|
||||
with patch(
|
||||
'crum.get_current_request',
|
||||
return_value=mock_request
|
||||
):
|
||||
fragment = partition.access_denied_fragment(mock_block, global_staff, FULL_ACCESS, 'test_allowed_group')
|
||||
self.assertIsNone(fragment)
|
||||
message = partition.access_denied_message(mock_block, global_staff, FULL_ACCESS, 'test_allowed_group')
|
||||
self.assertIsNone(message)
|
||||
|
||||
def test_acess_denied_fragment_for_null_request(self):
|
||||
"""
|
||||
Verifies the access denied fragment is visible when HTTP request is not available.
|
||||
@@ -120,6 +145,6 @@ class TestContentTypeGatingPartition(CacheIsolationTestCase):
|
||||
'openedx.features.content_type_gating.partitions.ContentTypeGatingPartition._is_audit_enrollment',
|
||||
return_value=True
|
||||
):
|
||||
fragment = partition.access_denied_fragment(mock_block, global_staff, 'test_group', 'test_allowed_group')
|
||||
fragment = partition.access_denied_fragment(mock_block, global_staff, GroupFactory(), 'test_allowed_group')
|
||||
|
||||
self.assertIsNotNone(fragment)
|
||||
|
||||
Reference in New Issue
Block a user