This reverts commit a67b9f70a16a0f16a842aad84754b245a2480b5f, reinstating commit cf78660ed35712f9bb7c112f70411179070d7382. The original commit was reverted because I thought I found bugs in it while verifying it on Stage, but it turns out that it was simply misconfigured Stage data that causing errors. The original commit's message has has been copied below: This commit completes the program_enrollments LMS app Python API for the time being. It does the following: * Add bulk-lookup of users by external key in api/reading.py * Add bulk-writing of program enrollments in api/writing.py * Move grade-reading to api/grades.py * Refactor api/linking.py to use api/writing.py * Refactor signals.py to use api/linking.py * Update rest_api/v1/views.py to utilize all these changes * Update linking management command and support tool to use API * Remove outdated tests from test_models.py * Misc. cleanup EDUCATOR-4321
58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
ProgramEnrollment internal API intended for Enterprise API.
|
|
|
|
This is not part of the program_enrollments Python API.
|
|
|
|
The Enterprise API currently depends on this module being present with these
|
|
functions, as implemented in ./utils.py. This module will be refactored
|
|
away in https://openedx.atlassian.net/browse/ENT-2294
|
|
"""
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
from lms.djangoapps.bulk_email.api import get_emails_enabled as get_emails_enabled_util
|
|
from lms.djangoapps.course_api.api import get_course_run_url as get_course_run_url_util
|
|
from lms.djangoapps.course_api.api import get_due_dates as get_due_dates_util
|
|
|
|
|
|
def get_due_dates(request, course_key, user):
|
|
"""
|
|
Get due date information for a user for blocks in a course.
|
|
Arguments:
|
|
request: the request object
|
|
course_key (CourseKey): the CourseKey for the course
|
|
user: the user object for which we want due date information
|
|
Returns:
|
|
due_dates (list): a list of dictionaries containing due date information
|
|
keys:
|
|
name: the display name of the block
|
|
url: the deep link to the block
|
|
date: the due date for the block
|
|
"""
|
|
return get_due_dates_util(request, course_key, user)
|
|
|
|
|
|
def get_course_run_url(request, course_id):
|
|
"""
|
|
Get the URL to a course run.
|
|
Arguments:
|
|
request: the request object
|
|
course_id (string): the course id of the course
|
|
Returns:
|
|
(string): the URL to the course run associated with course_id
|
|
"""
|
|
return get_course_run_url_util(request, course_id)
|
|
|
|
|
|
def get_emails_enabled(user, course_id):
|
|
"""
|
|
Get whether or not emails are enabled in the context of a course.
|
|
Arguments:
|
|
user: the user object for which we want to check whether emails are enabled
|
|
course_id (string): the course id of the course
|
|
Returns:
|
|
(bool): True if emails are enabled for the course associated with course_id for the user;
|
|
False otherwise
|
|
"""
|
|
return get_emails_enabled_util(user, course_id)
|