fix: Stop showing course certificate buttons to beta testers (#28416)

Beta testers can’t earn course certificates, so they should not see a “Request Certificate” button or other info describing how they can earn a cert.

MICROBA-992
This commit is contained in:
Christie Rice
2021-08-10 09:06:14 -04:00
committed by GitHub
parent f2bb92bc64
commit cf3a6c16d6
9 changed files with 127 additions and 19 deletions

View File

@@ -112,3 +112,11 @@ def update_forum_role(course_id, user, rolename, action):
role.users.remove(user)
else:
raise ValueError(f"unrecognized action '{action}'")
def is_beta_tester(user, course_id):
"""
Returns True if the user is a beta tester in this course, and False if not
"""
beta_testers_queryset = list_with_level(course_id, 'beta')
return beta_testers_queryset.filter(username=user.username).exists()

View File

@@ -10,6 +10,7 @@ from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.instructor.access import (
allow_access,
list_with_level,
is_beta_tester,
revoke_access,
update_forum_role
)
@@ -47,6 +48,12 @@ class TestInstructorAccessList(SharedModuleStoreTestCase):
assert set(beta_testers) == set(self.beta_testers)
assert set(beta_testers_alternative) == set(self.beta_testers)
def test_is_beta(self):
beta_tester = self.beta_testers[0]
user = UserFactory.create()
assert is_beta_tester(beta_tester, self.course.id)
assert not is_beta_tester(user, self.course.id)
class TestInstructorAccessAllow(EmailTemplateTagMixin, SharedModuleStoreTestCase):
""" Test access allow. """