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
66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
"""
|
|
Exceptions raised by functions exposed by program_enrollments Django app.
|
|
"""
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
# Every `__init__` here calls empty Exception() constructor.
|
|
# pylint: disable=super-init-not-called
|
|
|
|
|
|
class ProgramDoesNotExistException(Exception):
|
|
|
|
def __init__(self, program_uuid):
|
|
self.program_uuid = program_uuid
|
|
|
|
def __str__(self):
|
|
return 'Unable to find catalog program matching uuid {}'.format(self.program_uuid)
|
|
|
|
|
|
class OrganizationDoesNotExistException(Exception):
|
|
pass
|
|
|
|
|
|
class ProgramHasNoAuthoringOrganizationException(OrganizationDoesNotExistException):
|
|
|
|
def __init__(self, program_uuid):
|
|
self.program_uuid = program_uuid
|
|
|
|
def __str__(self):
|
|
return (
|
|
'Cannot determine authoring organization key for catalog program {}'
|
|
).format(self.program_uuid)
|
|
|
|
|
|
class BadOrganizationShortNameException(OrganizationDoesNotExistException):
|
|
|
|
def __init__(self, organization_short_name):
|
|
self.organization_short_name = organization_short_name
|
|
|
|
def __str__(self):
|
|
return 'Unable to find organization for short_name {}'.format(
|
|
self.organization_short_name
|
|
)
|
|
|
|
|
|
class ProviderDoesNotExistException(Exception):
|
|
|
|
def __init__(self, organization):
|
|
self.organization = organization
|
|
|
|
def __str__(self):
|
|
return 'Unable to find organization for short_name {}'.format(
|
|
self.organization.id
|
|
)
|
|
|
|
|
|
class ProviderConfigurationException(Exception):
|
|
|
|
def __init__(self, organization):
|
|
self.organization = organization
|
|
|
|
def __str__(self):
|
|
return (
|
|
'Multiple active SAML configurations found for organization={}. '
|
|
'Expected one.'
|
|
).format(self.organization.short_name)
|