Files
edx-platform/lms/djangoapps/bulk_email/api.py
Chris Pappas 4c9af183cb ENT-2294 | Moving utility functions in program enrollments to places … (#21752)
* ENT-2294 | Moving utility functions in program enrollments to places related to the data they manipulate

* updating a mock path

* minor test fix
2019-09-24 10:07:38 -04:00

31 lines
899 B
Python

# pylint: disable=unused-import
"""
Python APIs exposed by the bulk_email app to other in-process apps.
"""
# Public Bulk Email Functions
from __future__ import absolute_import
from bulk_email.models_api import (
is_bulk_email_enabled_for_course,
is_bulk_email_feature_enabled,
is_user_opted_out_for_course
)
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
"""
if is_bulk_email_feature_enabled(course_id=course_id):
return not is_user_opted_out_for_course(user=user, course_id=course_id)
return None