Files
edx-platform/lms/djangoapps/program_enrollments/constants.py
Kyle McCormick 151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00

131 lines
3.6 KiB
Python

"""
Constants used throughout the program_enrollments app and exposed to other
in-process apps through api.py.
"""
from common.djangoapps.student.roles import CourseStaffRole
class ProgramEnrollmentStatuses(object):
"""
Status that a user may have enrolled in a program.
TODO: Define the semantics of each of these (EDUCATOR-4958)
"""
ENROLLED = 'enrolled'
PENDING = 'pending'
SUSPENDED = 'suspended'
CANCELED = 'canceled'
ENDED = 'ended'
__ACTIVE__ = (ENROLLED, PENDING)
__ALL__ = (ENROLLED, PENDING, SUSPENDED, CANCELED, ENDED)
# Note: Any changes to this value will trigger a migration on
# ProgramEnrollment!
__MODEL_CHOICES__ = (
(status, status) for status in __ALL__
)
class ProgramCourseEnrollmentStatuses(object):
"""
Status that a user may have enrolled in a course.
TODO: Consider whether we need these (EDUCATOR-4958)
"""
ACTIVE = 'active'
INACTIVE = 'inactive'
__ALL__ = (ACTIVE, INACTIVE)
# Note: Any changes to this value will trigger a migration on
# ProgramCourseEnrollment!
__MODEL_CHOICES__ = (
(status, status) for status in __ALL__
)
class _EnrollmentErrorStatuses(object):
"""
Error statuses common to program and program-course enrollments responses.
"""
# Same student key supplied more than once.
DUPLICATED = 'duplicated'
# Requested target status is invalid
INVALID_STATUS = "invalid-status"
# In the case of a POST request, the enrollment already exists.
CONFLICT = "conflict"
# Although the request is syntactically valid,
# the change being made is not supported.
# For example, it may be illegal to change a user's status back to A
# after changing it to B, where A and B are two hypothetical enrollment
# statuses.
ILLEGAL_OPERATION = "illegal-operation"
# Could not modify program enrollment or create program-course
# enrollment because the student is not enrolled in the program in the
# first place.
NOT_IN_PROGRAM = "not-in-program"
# Something unexpected went wrong.
# If API users are seeing this, we need to investigate.
INTERNAL_ERROR = "internal-error"
__ALL__ = (
DUPLICATED,
INVALID_STATUS,
CONFLICT,
ILLEGAL_OPERATION,
NOT_IN_PROGRAM,
INTERNAL_ERROR,
)
class ProgramOperationStatuses(
ProgramEnrollmentStatuses,
_EnrollmentErrorStatuses,
):
"""
Valid program enrollment operation statuses.
Combines error statuses and OK statuses.
"""
__OK__ = ProgramEnrollmentStatuses.__ALL__
__ERRORS__ = _EnrollmentErrorStatuses.__ALL__
__ALL__ = __OK__ + __ERRORS__
class ProgramCourseOperationStatuses(
ProgramCourseEnrollmentStatuses,
_EnrollmentErrorStatuses,
):
"""
Valid program-course enrollment operation statuses.
Combines error statuses and OK statuses.
"""
# Could not modify program-course enrollment because the user
# is not enrolled in the course in the first place.
NOT_FOUND = "not-found"
__OK__ = ProgramCourseEnrollmentStatuses.__ALL__
__ERRORS__ = (NOT_FOUND,) + _EnrollmentErrorStatuses.__ALL__
__ALL__ = __OK__ + __ERRORS__
class ProgramCourseEnrollmentRoles(object):
"""
Valid roles that can be assigned as part of a ProgramCourseEnrollment
"""
COURSE_STAFF = CourseStaffRole.ROLE
__ALL__ = (COURSE_STAFF,)
# Note: Any changes to this value will trigger a migration on
# CourseAccessRoleAssignment!
__MODEL_CHOICES__ = (
(role, role) for role in __ALL__
)