Merge branch 'master' into edx-depr31
This commit is contained in:
@@ -110,11 +110,11 @@ def get_credentials(user, program_uuid=None, credential_type=None):
|
||||
)
|
||||
|
||||
|
||||
def get_courses_completion_status(lms_user_id, course_run_ids):
|
||||
def get_courses_completion_status(username, course_run_ids):
|
||||
"""
|
||||
Given the lms_user_id and course run ids, checks for course completion status
|
||||
Given the username and course run ids, checks for course completion status
|
||||
Arguments:
|
||||
lms_user_id (User): The user to authenticate as when requesting credentials.
|
||||
username (User): Username of the user whose credentials are being requested.
|
||||
course_run_ids(List): list of course run ids for which we need to check the completion status
|
||||
Returns:
|
||||
list of course_run_ids for which user has completed the course
|
||||
@@ -134,7 +134,7 @@ def get_courses_completion_status(lms_user_id, course_run_ids):
|
||||
api_response = api_client.post(
|
||||
completion_status_url,
|
||||
json={
|
||||
'lms_user_id': lms_user_id,
|
||||
'username': username,
|
||||
'course_runs': course_run_ids,
|
||||
}
|
||||
)
|
||||
@@ -142,16 +142,16 @@ def get_courses_completion_status(lms_user_id, course_run_ids):
|
||||
course_completion_response = api_response.json()
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
log.exception("An unexpected error occurred while reqeusting course completion statuses "
|
||||
"for lms_user_id [%s] for course_run_ids [%s] with exc [%s]:",
|
||||
lms_user_id,
|
||||
"for user [%s] for course_run_ids [%s] with exc [%s]:",
|
||||
username,
|
||||
course_run_ids,
|
||||
exc
|
||||
)
|
||||
return [], True
|
||||
# Yes, This is course_credentials_data. The key is named status but
|
||||
# it contains all the courses data from credentials.
|
||||
log.info("Course completion status response for lms_user_id [%s] for course_run_ids [%s] is [%s]",
|
||||
lms_user_id,
|
||||
log.info("Course completion status response for user [%s] for course_run_ids [%s] is [%s]",
|
||||
username,
|
||||
course_run_ids,
|
||||
course_completion_response)
|
||||
course_credentials_data = course_completion_response.get('status', [])
|
||||
@@ -159,8 +159,8 @@ def get_courses_completion_status(lms_user_id, course_run_ids):
|
||||
filtered_records = [course_data['course_run']['key'] for course_data in course_credentials_data if
|
||||
course_data['course_run']['key'] in course_run_ids and
|
||||
course_data['status'] == settings.CREDENTIALS_COURSE_COMPLETION_STATE]
|
||||
log.info("Filtered course completion status response for lms_user_id [%s] for course_run_ids [%s] is [%s]",
|
||||
lms_user_id,
|
||||
log.info("Filtered course completion status response for user [%s] for course_run_ids [%s] is [%s]",
|
||||
username,
|
||||
course_run_ids,
|
||||
filtered_records)
|
||||
return filtered_records, False
|
||||
|
||||
@@ -28,7 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
def _encode_secret(secret, provider_id):
|
||||
"""
|
||||
Helper function for encoding text_type secrets into ascii.
|
||||
Helper function for encoding string secrets into ascii.
|
||||
"""
|
||||
try:
|
||||
secret.encode('ascii')
|
||||
|
||||
@@ -52,3 +52,7 @@ class EnrollmentApiLoadError(CourseEnrollmentError):
|
||||
class InvalidEnrollmentAttribute(CourseEnrollmentError):
|
||||
"""Enrollment Attributes could not be validated"""
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
|
||||
class CourseEnrollmentNotUpdatableError(CourseEnrollmentError):
|
||||
"""The requested enrollment could not be updated."""
|
||||
|
||||
@@ -8,7 +8,10 @@ from .models import CourseNotificationPreference, Notification
|
||||
|
||||
|
||||
class NotificationAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
"""
|
||||
Admin for Notifications
|
||||
"""
|
||||
raw_id_fields = ('user',)
|
||||
|
||||
|
||||
class CourseNotificationPreferenceAdmin(admin.ModelAdmin):
|
||||
@@ -16,6 +19,7 @@ class CourseNotificationPreferenceAdmin(admin.ModelAdmin):
|
||||
Admin for Course Notification Preferences
|
||||
"""
|
||||
model = CourseNotificationPreference
|
||||
raw_id_fields = ('user',)
|
||||
list_display = ['get_username', 'course_id', 'notification_preference_config']
|
||||
|
||||
@admin.display(description='Username', ordering='user__username')
|
||||
|
||||
Reference in New Issue
Block a user