refactor: Rename whitelist to allowlist (#27533)

MICROBA-1021
This commit is contained in:
Christie Rice
2021-05-12 09:51:26 -04:00
committed by GitHub
parent c651e58fb7
commit 1473973b2b
6 changed files with 66 additions and 48 deletions

View File

@@ -16,6 +16,8 @@ from lms.djangoapps.certificates.api import (
generate_certificate_task,
generate_user_certificates,
get_allowlisted_users,
get_enrolled_allowlisted_users,
get_enrolled_allowlisted_not_passing_users,
is_using_v2_course_certificates,
)
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
@@ -39,21 +41,12 @@ def generate_students_certificates(
student_set = task_input.get('student_set')
if student_set == 'all_whitelisted':
# Generate Certificates for all white listed students.
students_to_generate_certs_for = students_to_generate_certs_for.filter(
certificatewhitelist__course_id=course_id,
certificatewhitelist__whitelist=True
)
# Generate Certificates for all allowlisted students.
students_to_generate_certs_for = get_enrolled_allowlisted_users(course_id)
elif student_set == 'whitelisted_not_generated':
# Whitelist students who did not get certificates already.
students_to_generate_certs_for = students_to_generate_certs_for.filter(
certificatewhitelist__course_id=course_id,
certificatewhitelist__whitelist=True
).exclude(
generatedcertificate__course_id=course_id,
generatedcertificate__status__in=CertificateStatuses.PASSED_STATUSES
)
# Allowlisted students who did not yet receive certificates
students_to_generate_certs_for = get_enrolled_allowlisted_not_passing_users(course_id)
elif student_set == "specific_student":
specific_student_id = task_input.get('specific_student_id')

View File

@@ -19,7 +19,8 @@ from six.moves import zip_longest
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.roles import BulkRoleCache
from lms.djangoapps.certificates.models import CertificateWhitelist, GeneratedCertificate, certificate_info_for_user
from lms.djangoapps.certificates import api as certs_api
from lms.djangoapps.certificates.models import GeneratedCertificate, certificate_info_for_user
from lms.djangoapps.course_blocks.api import get_course_blocks
from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient
from lms.djangoapps.grades.api import CourseGradeFactory
@@ -358,8 +359,8 @@ class _ProblemGradeReportContext:
class _CertificateBulkContext:
def __init__(self, context, users):
certificate_whitelist = CertificateWhitelist.objects.filter(course_id=context.course_id, whitelist=True)
self.whitelisted_user_ids = [entry.user_id for entry in certificate_whitelist]
certificate_allowlist = certs_api.get_allowlist(context.course_id)
self.allowlisted_user_ids = [entry['user_id'] for entry in certificate_allowlist]
self.certificates_by_user = {
certificate.user.id: certificate
for certificate in
@@ -661,12 +662,12 @@ class CourseGradeReport:
"""
Returns the course certification information for the given user.
"""
is_whitelisted = user.id in bulk_certs.whitelisted_user_ids
is_allowlisted = user.id in bulk_certs.allowlisted_user_ids
certificate_info = certificate_info_for_user(
user,
context.course_id,
course_grade.letter_grade,
is_whitelisted,
is_allowlisted,
bulk_certs.certificates_by_user.get(user.id),
)
return certificate_info

View File

@@ -1910,7 +1910,6 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
def _create_user_data(self,
user_enroll_mode,
has_passed,
whitelisted,
verification_status,
certificate_status,
certificate_mode):
@@ -1923,7 +1922,7 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
if has_passed:
self.submit_student_answer('u1', 'test_problem', ['choice_1'])
CertificateAllowlistFactory.create(user=user, course_id=self.course.id, whitelist=whitelisted)
CertificateAllowlistFactory.create(user=user, course_id=self.course.id)
if user_enroll_mode in CourseMode.VERIFIED_MODES:
SoftwareSecurePhotoVerificationFactory.create(user=user, status=verification_status)
@@ -1939,19 +1938,19 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
@ddt.data(
(
'verified', False, False, 'approved', 'notpassing', 'honor',
['verified', 'ID Verified', 'N', 'N', 'N/A']
'verified', False, 'approved', 'notpassing', 'honor',
['verified', 'ID Verified', 'Y', 'N', 'N/A']
),
(
'verified', False, True, 'approved', 'downloadable', 'verified',
'verified', False, 'approved', 'downloadable', 'verified',
['verified', 'ID Verified', 'Y', 'Y', 'verified']
),
(
'honor', True, True, 'approved', 'restricted', 'honor',
'honor', True, 'approved', 'restricted', 'honor',
['honor', 'N/A', 'Y', 'N', 'N/A']
),
(
'verified', True, True, 'must_retry', 'downloadable', 'honor',
'verified', True, 'must_retry', 'downloadable', 'honor',
['verified', 'Not ID Verified', 'Y', 'Y', 'honor']
),
)
@@ -1960,7 +1959,6 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
self,
user_enroll_mode,
has_passed,
whitelisted,
verification_status,
certificate_status,
certificate_mode,
@@ -1970,7 +1968,6 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
user = self._create_user_data(
user_enroll_mode,
has_passed,
whitelisted,
verification_status,
certificate_status,
certificate_mode
@@ -2010,7 +2007,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
# Allowlist 5 students
for student in students[2:7]:
CertificateAllowlistFactory.create(user=student, course_id=self.course.id, whitelist=True)
CertificateAllowlistFactory.create(user=student, course_id=self.course.id,)
task_input = {'student_set': None}
expected_results = {
@@ -2041,7 +2038,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
# Allowlist 3 students
for student in students[:3]:
CertificateAllowlistFactory.create(
user=student, course_id=self.course.id, whitelist=True
user=student, course_id=self.course.id
)
# Grant certs to 2 students
@@ -2091,7 +2088,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
# Allowlist 4 students
for student in students[:4]:
CertificateAllowlistFactory.create(
user=student, course_id=self.course.id, whitelist=True
user=student, course_id=self.course.id
)
task_input = {'student_set': 'whitelisted_not_generated'}
@@ -2116,7 +2113,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
Tests generating a certificate for a specific student.
"""
student = self.create_student(username="Hamnet", email="ham@ardenforest.co.uk")
CertificateAllowlistFactory.create(user=student, course_id=self.course.id, whitelist=True)
CertificateAllowlistFactory.create(user=student, course_id=self.course.id)
task_input = {
'student_set': 'specific_student',
'specific_student_id': student.id
@@ -2188,7 +2185,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
# Allowlist 7 students
for student in students[:7]:
CertificateAllowlistFactory.create(user=student, course_id=self.course.id, whitelist=True)
CertificateAllowlistFactory.create(user=student, course_id=self.course.id)
# Certificates should be regenerated for students having generated certificates with status
# 'downloadable' or 'error' which are total of 5 students in this test case
@@ -2261,7 +2258,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
# Allowlist 7 students
for student in students[:7]:
CertificateAllowlistFactory.create(user=student, course_id=self.course.id, whitelist=True)
CertificateAllowlistFactory.create(user=student, course_id=self.course.id)
# Regenerated certificates for students having generated certificates with status
# 'deleted' or 'generating'
@@ -2332,7 +2329,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
# Allowlist all students
for student in students[:]:
CertificateAllowlistFactory.create(user=student, course_id=self.course.id, whitelist=True)
CertificateAllowlistFactory.create(user=student, course_id=self.course.id)
# Regenerated certificates for students having generated certificates with status
# 'downloadable', 'error' or 'generating'
@@ -2403,7 +2400,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
# Allowlist 7 students
for student in students[:7]:
CertificateAllowlistFactory.create(user=student, course_id=self.course.id, whitelist=True)
CertificateAllowlistFactory.create(user=student, course_id=self.course.id)
# Certificates should be regenerated for students having generated certificates with status
# 'downloadable' or 'error' which are total of 5 students in this test case