openedx.core.djangoapps.user_api package#
Subpackages#
- openedx.core.djangoapps.user_api.accounts package
- Submodules
- openedx.core.djangoapps.user_api.accounts.api module
get_account_settings()get_confirm_email_validation_error()get_country_validation_error()get_email_existence_validation_error()get_email_validation_error()get_name_validation_error()get_password_validation_error()get_profile_images()get_secondary_email_validation_error()get_username_existence_validation_error()get_username_validation_error()update_account_settings()
- openedx.core.djangoapps.user_api.accounts.forms module
- openedx.core.djangoapps.user_api.accounts.image_helpers module
- openedx.core.djangoapps.user_api.accounts.permissions module
- openedx.core.djangoapps.user_api.accounts.serializers module
AccountLegacyProfileSerializerAccountLegacyProfileSerializer.MetaAccountLegacyProfileSerializer.convert_empty_to_None()AccountLegacyProfileSerializer.get_profile_image()AccountLegacyProfileSerializer.get_requires_parental_consent()AccountLegacyProfileSerializer.transform_bio()AccountLegacyProfileSerializer.transform_country()AccountLegacyProfileSerializer.transform_gender()AccountLegacyProfileSerializer.transform_level_of_education()AccountLegacyProfileSerializer.transform_phone_number()AccountLegacyProfileSerializer.update()AccountLegacyProfileSerializer.validate_bio()AccountLegacyProfileSerializer.validate_language_proficiencies()AccountLegacyProfileSerializer.validate_name()AccountLegacyProfileSerializer.validate_social_links()
AccountUserSerializerLanguageProficiencySerializerPendingNameChangeSerializerPhoneNumberSerializerRetirementStateSerializerRetirementUserProfileSerializerRetirementUserSerializerSocialLinkSerializerUserAccountDisableHistorySerializerUserReadOnlySerializerUserRetirementPartnerReportSerializerUserRetirementStatusSerializerUserSearchEmailSerializerget_extended_profile()get_profile_visibility()
- openedx.core.djangoapps.user_api.accounts.signals module
- openedx.core.djangoapps.user_api.accounts.utils module
- openedx.core.djangoapps.user_api.accounts.views module
AccountDeactivationViewAccountRetirementPartnerReportViewAccountRetirementPartnerReportView.DELETION_COMPLETED_KEYAccountRetirementPartnerReportView.ORGS_CONFIG_FIELD_HEADINGS_KEYAccountRetirementPartnerReportView.ORGS_CONFIG_KEYAccountRetirementPartnerReportView.ORGS_CONFIG_ORG_KEYAccountRetirementPartnerReportView.ORIGINAL_EMAIL_KEYAccountRetirementPartnerReportView.ORIGINAL_NAME_KEYAccountRetirementPartnerReportView.STUDENT_ID_KEYAccountRetirementPartnerReportView.basenameAccountRetirementPartnerReportView.descriptionAccountRetirementPartnerReportView.detailAccountRetirementPartnerReportView.nameAccountRetirementPartnerReportView.parser_classesAccountRetirementPartnerReportView.permission_classesAccountRetirementPartnerReportView.retirement_partner_cleanup()AccountRetirementPartnerReportView.retirement_partner_report()AccountRetirementPartnerReportView.retirement_partner_status_create()AccountRetirementPartnerReportView.serializer_classAccountRetirementPartnerReportView.suffix
AccountRetirementStatusViewAccountRetirementStatusView.basenameAccountRetirementStatusView.cleanup()AccountRetirementStatusView.descriptionAccountRetirementStatusView.detailAccountRetirementStatusView.nameAccountRetirementStatusView.parser_classesAccountRetirementStatusView.partial_update()AccountRetirementStatusView.permission_classesAccountRetirementStatusView.retirement_queue()AccountRetirementStatusView.retirements_by_status_and_date()AccountRetirementStatusView.retrieve()AccountRetirementStatusView.serializer_classAccountRetirementStatusView.suffix
AccountRetirementViewAccountRetirementView.basenameAccountRetirementView.clear_pii_from_certificate_records()AccountRetirementView.clear_pii_from_userprofile()AccountRetirementView.delete_users_country_cache()AccountRetirementView.delete_users_profile_images()AccountRetirementView.descriptionAccountRetirementView.detailAccountRetirementView.nameAccountRetirementView.parser_classesAccountRetirementView.permission_classesAccountRetirementView.post()AccountRetirementView.retire_entitlement_support_detail()AccountRetirementView.suffix
AccountViewSetAccountViewSet.account_user_get_responsesAccountViewSet.authentication_classesAccountViewSet.basenameAccountViewSet.descriptionAccountViewSet.detailAccountViewSet.get()AccountViewSet.list()AccountViewSet.nameAccountViewSet.parser_classesAccountViewSet.partial_update()AccountViewSet.permission_classesAccountViewSet.retrieve()AccountViewSet.search_emails()AccountViewSet.suffix
CancelAccountRetirementStatusViewCancelAccountRetirementStatusView.basenameCancelAccountRetirementStatusView.cancel_retirement()CancelAccountRetirementStatusView.descriptionCancelAccountRetirementStatusView.detailCancelAccountRetirementStatusView.nameCancelAccountRetirementStatusView.permission_classesCancelAccountRetirementStatusView.suffix
DeactivateLogoutViewLMSAccountRetirementViewNameChangeViewUsernameReplacementViewrequest_requires_username()
- Module contents
- openedx.core.djangoapps.user_api.course_tag package
- openedx.core.djangoapps.user_api.management package
- Subpackages
- openedx.core.djangoapps.user_api.management.commands package
- Submodules
- openedx.core.djangoapps.user_api.management.commands.bulk_user_org_email_optout module
- openedx.core.djangoapps.user_api.management.commands.cancel_user_retirement_request module
- openedx.core.djangoapps.user_api.management.commands.create_user_gdpr_testing module
- openedx.core.djangoapps.user_api.management.commands.email_opt_in_list module
- openedx.core.djangoapps.user_api.management.commands.migrate_user_profile_langs module
- openedx.core.djangoapps.user_api.management.commands.populate_enterprise_learner_current_job module
- openedx.core.djangoapps.user_api.management.commands.populate_retirement_states module
- openedx.core.djangoapps.user_api.management.commands.retire_user module
- openedx.core.djangoapps.user_api.management.commands.sync_hubspot_contacts module
- Module contents
- openedx.core.djangoapps.user_api.management.commands package
- Module contents
- Subpackages
- openedx.core.djangoapps.user_api.preferences package
- openedx.core.djangoapps.user_api.verification_api package
Submodules#
openedx.core.djangoapps.user_api.api module#
Python APIs exposed by the user_api app to other in-process apps.
- openedx.core.djangoapps.user_api.api.get_retired_user_ids()#
Returns a list of learners’ user_ids who have retired their account. This utility method removes any learners who are in the “PENDING” retirement state, they have _requested_ retirement but have yet to have all their data purged. These learners are still within their cooloff period where they can submit a request to restore their account.
- Parameters:
None
- Returns:
- list[int] - A list of user ids of learners who have retired their account, minus any accounts currently in the
”PENDING” state.
openedx.core.djangoapps.user_api.errors module#
Errors thrown by the various user APIs.
- exception openedx.core.djangoapps.user_api.errors.AccountCountryInvalid#
Bases:
AccountRequestErrorThe requested country does not exist.
- exception openedx.core.djangoapps.user_api.errors.AccountDataBadLength#
Bases:
AccountRequestErrorThe requested account data is either too short or too long.
- exception openedx.core.djangoapps.user_api.errors.AccountDataBadType#
Bases:
AccountRequestErrorThe requested account data is of the wrong type.
- exception openedx.core.djangoapps.user_api.errors.AccountEmailAlreadyExists#
Bases:
AccountRequestErrorUser with the same email already exists.
- exception openedx.core.djangoapps.user_api.errors.AccountEmailInvalid#
Bases:
AccountRequestErrorThe requested email is not in a valid format.
- exception openedx.core.djangoapps.user_api.errors.AccountPasswordInvalid#
Bases:
AccountRequestErrorThe requested password is not in a valid format.
- exception openedx.core.djangoapps.user_api.errors.AccountRequestError#
Bases:
UserAPIRequestErrorThere was a problem with the request to the account API.
- exception openedx.core.djangoapps.user_api.errors.AccountUpdateError(developer_message, user_message=None)#
Bases:
AccountRequestErrorAn update to the account failed. More detailed information is present in developer_message, and depending on the type of error encountered, there may also be a non-null user_message field.
- exception openedx.core.djangoapps.user_api.errors.AccountUserAlreadyExists#
Bases:
AccountRequestErrorUser with the same username and/or email already exists.
- exception openedx.core.djangoapps.user_api.errors.AccountUsernameAlreadyExists#
Bases:
AccountRequestErrorUser with the same username already exists.
- exception openedx.core.djangoapps.user_api.errors.AccountUsernameInvalid#
Bases:
AccountRequestErrorThe requested username is not in a valid format.
- exception openedx.core.djangoapps.user_api.errors.AccountValidationError(field_errors)#
Bases:
AccountRequestErrorValidation issues were found with the supplied data. More detailed information is present in field_errors, a dict with specific information about each field that failed validation. For each field, there will be at least a developer_message describing the validation issue, and possibly also a user_message.
- exception openedx.core.djangoapps.user_api.errors.CountryCodeError#
Bases:
ValueErrorThere was a problem with the country code
- exception openedx.core.djangoapps.user_api.errors.PreferenceRequestError#
Bases:
UserAPIRequestErrorThere was a problem with a preference request.
- exception openedx.core.djangoapps.user_api.errors.PreferenceUpdateError(developer_message, user_message=None)#
Bases:
PreferenceRequestErrorAn update to a user preference failed. More detailed information is present in developer_message, and depending on the type of error encountered, there may also be a non-null user_message field.
- exception openedx.core.djangoapps.user_api.errors.PreferenceValidationError(preference_errors)#
Bases:
PreferenceRequestErrorValidation issues were found with the supplied data. More detailed information is present in preference_errors, a dict with specific information about each preference that failed validation. For each preference, there will be at least a developer_message describing the validation issue, and possibly also a user_message.
- exception openedx.core.djangoapps.user_api.errors.UserAPIInternalError#
Bases:
ExceptionAn internal error occurred in the User API.
- exception openedx.core.djangoapps.user_api.errors.UserAPIRequestError#
Bases:
ExceptionThere was a problem with the request to the User API.
- exception openedx.core.djangoapps.user_api.errors.UserNotAuthorized#
Bases:
UserAPIRequestErrorThe user is not authorized to perform the requested action.
- exception openedx.core.djangoapps.user_api.errors.UserNotFound#
Bases:
UserAPIRequestErrorThe requested user does not exist.
openedx.core.djangoapps.user_api.helpers module#
Helper functions for the account/profile Python APIs. This is NOT part of the public API.
- class openedx.core.djangoapps.user_api.helpers.FormDescription(method, submit_url)#
Bases:
objectGenerate a JSON representation of a form.
- ALLOWED_RESTRICTIONS = {'email': ['min_length', 'max_length', 'readonly'], 'password': ['min_length', 'max_length', 'min_upper', 'min_lower', 'min_punctuation', 'min_symbol', 'min_numeric', 'min_alphabetic'], 'text': ['min_length', 'max_length']}#
- ALLOWED_TYPES = ['text', 'email', 'select', 'textarea', 'checkbox', 'plaintext', 'password', 'hidden']#
- FIELD_TYPE_MAP = {<class 'django.forms.fields.BooleanField'>: 'checkbox', <class 'django.forms.fields.CharField'>: 'text', <class 'django.forms.fields.ChoiceField'>: 'select', <class 'django.forms.fields.EmailField'>: 'email', <class 'django.forms.fields.TypedChoiceField'>: 'select', <class 'django.forms.widgets.PasswordInput'>: 'password', <class 'django.forms.widgets.Textarea'>: 'textarea'}#
- OVERRIDE_FIELD_PROPERTIES = ['label', 'type', 'defaultValue', 'placeholder', 'instructions', 'required', 'restrictions', 'options', 'supplementalLink', 'supplementalText']#
- add_field(name, label='', field_type='text', default='', placeholder='', instructions='', exposed=None, required=True, restrictions=None, options=None, include_default_option=False, error_messages=None, supplementalLink='', supplementalText='')#
Add a field to the form description.
- Parameters:
name (unicode) – The name of the field, which is the key for the value to send back to the server.
- Keyword Arguments:
label (unicode) – The label for the field (e.g. “E-mail” or “Username”)
field_type (unicode) – The type of the field. See ALLOWED_TYPES for acceptable values.
default (unicode) – The default value for the field.
placeholder (unicode) – Placeholder text in the field (e.g. “user@example.com” for an email field)
instructions (unicode) – Short instructions for using the field (e.g. “This is the email address you used when you registered.”)
exposed (boolean) – Whether the field is shown if not required. If the field is not set, the field will be visible if it’s required.
required (boolean) – Whether the field is required or optional.
restrictions (dict) – Validation restrictions for the field. See ALLOWED_RESTRICTIONS for acceptable values.
options (list) – For “select” fields, a list of tuples (value, display_name) representing the options available to the user. value is the value of the field to send to the server, and display_name is the name to display to the user. If the field type is “select”, you must provide this kwarg.
include_default_option (boolean) – If True, include a “default” empty option at the beginning of the options list.
error_messages (dict) – Custom validation error messages. Currently, the only supported key is “required” indicating that the messages should be displayed if the user does not provide a value for a required field.
supplementalLink (unicode) – A qualified URL to provide supplemental information for the form field. An example may be a link to documentation for creating strong passwords.
supplementalText (unicode) – The visible text for the supplemental link above.
- Raises:
- override_field_properties(field_name, **kwargs)#
Override properties of a field.
The overridden values take precedence over the values provided to add_field().
Field properties not in OVERRIDE_FIELD_PROPERTIES will be ignored.
- Parameters:
field_name (str) – The name of the field to override.
- Keyword Arguments:
add_field(). (Same as to)
- to_json()#
Create a JSON representation of the form description.
Here’s an example of the output: {
“method”: “post”, “submit_url”: “/submit”, “fields”: [
- {
“name”: “cheese_or_wine”, “label”: “Cheese or Wine?”, “defaultValue”: “cheese”, “type”: “select”, “exposed”: True, “required”: True, “placeholder”: “”, “instructions”: “”, “options”: [
{“value”: “cheese”, “name”: “Cheese”, “default”: False}, {“value”: “wine”, “name”: “Wine”, “default”: False}
] “restrictions”: {}, “errorMessages”: {},
}, {
“name”: “comments”, “label”: “comments”, “defaultValue”: “”, “type”: “text”, “exposed”: False, “required”: False, “placeholder”: “Any comments?”, “instructions”: “Please enter additional comments here.” “restrictions”: {
“max_length”: 200
} “errorMessages”: {},
]
}
If the field is NOT a “select” type, then the “options” key will be omitted.
- Returns:
unicode
- exception openedx.core.djangoapps.user_api.helpers.InvalidFieldError#
Bases:
ExceptionThe provided field definition is not valid.
- class openedx.core.djangoapps.user_api.helpers.LocalizedJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)#
Bases:
DjangoJSONEncoderJSON handler that evaluates gettext_lazy promises.
- default(obj)#
Forces evaluation of gettext_lazy promises.
- openedx.core.djangoapps.user_api.helpers.intercept_errors(api_error, ignore_errors=None)#
Function decorator that intercepts exceptions and translates them into API-specific errors (usually an “internal” error).
This allows callers to gracefully handle unexpected errors from the API.
This method will also log all errors and function arguments to make it easier to track down unexpected errors.
- Parameters:
api_error (Exception) – The exception to raise if an unexpected error is encountered.
- Keyword Arguments:
ignore_errors (iterable) – List of errors to ignore. By default, intercept every error.
- Returns:
function
- openedx.core.djangoapps.user_api.helpers.serializer_is_dirty(preference_serializer)#
Return True if saving the supplied (Raw)UserPreferenceSerializer would change the database.
openedx.core.djangoapps.user_api.legacy_urls module#
Defines the URL routes for this app.
openedx.core.djangoapps.user_api.message_types module#
Message Types for user_api emails
- class openedx.core.djangoapps.user_api.message_types.DeletionNotificationMessage(*args, **kwargs)#
Bases:
BaseMessageTypeMessage to notify learners that their account is queued for deletion.
openedx.core.djangoapps.user_api.middleware module#
Middleware for user api. Adds user’s tags to tracking event context.
- class openedx.core.djangoapps.user_api.middleware.UserTagsEventContextMiddleware(get_response)#
Bases:
MiddlewareMixinMiddleware that adds a user’s tags to tracking event context.
- CONTEXT_NAME = 'user_tags_context'#
- process_request(request)#
Add a user’s tags to the tracking event context.
- process_response(request, response)#
Exit the context if it exists.
openedx.core.djangoapps.user_api.models module#
Django ORM model specifications for the User API application
- class openedx.core.djangoapps.user_api.models.BulkUserRetirementConfig(*args, **kwargs)#
Bases:
ConfigurationModelConfiguration to store a csv file that will be used in retire_user management command.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- cache_timeout = 0#
- change_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- changed_by#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- changed_by_id#
- csv_file#
The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assign a file object on assignment so you can do:
>>> with open('/path/to/hello.world') as f: ... instance.file = File(f)
- enabled#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
- get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class openedx.core.djangoapps.user_api.models.RetirementState(*args, **kwargs)#
Bases:
ModelStores the list and ordering of the steps of retirement, this should almost never change as updating it can break the retirement process of users already in the queue.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- current_state#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- classmethod get_dead_end_state_names_list()#
- classmethod get_dead_end_states()#
- classmethod get_state_names_list()#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_dead_end_state#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_state#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- objects = <django.db.models.manager.Manager object>#
- required#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- state_execution_order#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- state_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- exception openedx.core.djangoapps.user_api.models.RetirementStateError#
Bases:
Exception
- class openedx.core.djangoapps.user_api.models.UserCourseTag(*args, **kwargs)#
Bases:
ModelPer-course user tags, to be used by various things that want to store tags about the user. Added initially to store assignment to experimental groups.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- course_id#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- key#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- user#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id#
- value#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class openedx.core.djangoapps.user_api.models.UserOrgTag(*args, **kwargs)#
Bases:
TimeStampedModel,DeletableByUserValuePer-Organization user tags.
Allows settings to be configured at an organization level.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- key#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- org#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id#
- value#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class openedx.core.djangoapps.user_api.models.UserPreference(*args, **kwargs)#
Bases:
ModelA user’s preference, stored as generic text to be processed by client
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- KEY_REGEX = '[-_a-zA-Z0-9]+'#
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- static get_all_preferences(user)#
Gets all preferences for a given user
Returns: Set of (preference type, value) pairs for each of the user’s preferences
- classmethod get_preference_for_users(user_ids, preference_key)#
Returns preference for list of users
- classmethod get_value(user, preference_key, default=None)#
Gets the user preference value for a given key.
Note
This method provides no authorization of access to the user preference. Consider using user_api.preferences.api.get_user_preference instead if this is part of a REST API request.
- Parameters:
user (User) – The user whose preference should be set.
preference_key (str) – The key for the user preference.
default – The object to return if user does not have preference key set
- Returns:
The user preference value, or default if one is not set.
- classmethod has_value(user, preference_key)#
Checks if the user has preference value for a given key.
Note
This method provides no authorization of access to the user preference. Consider using user_api.preferences.api.has_user_preference instead if this is part of a REST API request.
- Parameters:
user (User) – The user whose preference should be checked.
preference_key (str) – The key for the user preference.
- Returns:
True if user preference for the given key is set and False otherwise.
- Return type:
(bool)
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- key#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- user#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id#
- value#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class openedx.core.djangoapps.user_api.models.UserRetirementPartnerReportingStatus(*args, **kwargs)#
Bases:
TimeStampedModelWhen a user has been retired from LMS it will still need to be reported out to partners so they can forget the user also. This process happens on a very different, and asynchronous, timeline than LMS retirement and only impacts a subset of learners so it maintains a queue. This queue is populated as part of the LMS retirement process.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_being_processed#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- original_email#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- original_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- original_username#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user#
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- user_id#
- class openedx.core.djangoapps.user_api.models.UserRetirementRequest(*args, **kwargs)#
Bases:
TimeStampedModelRecords and perists every user retirement request. Users that have requested to cancel their retirement before retirement begins can be removed. All other retired users persist in this table forever.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- classmethod create_retirement_request(user)#
Creates a UserRetirementRequest for the specified user.
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- classmethod has_user_requested_retirement(user)#
Checks to see if a UserRetirementRequest has been created for the specified user.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- user#
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- user_id#
- class openedx.core.djangoapps.user_api.models.UserRetirementStatus(*args, **kwargs)#
Bases:
TimeStampedModelTracks the progress of a user’s retirement request
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- classmethod create_retirement(user)#
Creates a UserRetirementStatus for the given user, in the correct initial state. Will fail if the user already has a UserRetirementStatus row or if states are not yet populated.
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- current_state#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- current_state_id#
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- classmethod get_retirement_for_retirement_action(username)#
Convenience method to get a UseRetirementStatus for a particular user with some checking to make sure they’re in a state that is acceptable to be acted upon. The user should be in a “working state” (not a dead end state, PENDING, or *_COMPLETE). This should help a bit with situations like the retirement driver accidentally trying to act upon the same user twice at the same time, or trying to take action on an errored user.
Can raise UserRetirementStatus.DoesNotExist or RetirementStateError, otherwise should return a UserRetirementStatus
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_state#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- last_state_id#
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- original_email#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- original_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- original_username#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- responses#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- retired_email#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- retired_username#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- update_state(update)#
Perform the necessary checks for a state change and update the state and response if passed or throw a RetirementStateError with a useful error message
- user#
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- user_id#
- openedx.core.djangoapps.user_api.models.post_delete_callback(sender, **kwargs)#
Event changes to user preferences.
- openedx.core.djangoapps.user_api.models.post_save_callback(sender, **kwargs)#
Event changes to user preferences.
- openedx.core.djangoapps.user_api.models.pre_save_callback(sender, **kwargs)#
Event changes to user preferences.
- openedx.core.djangoapps.user_api.models.remove_pending_retirement_request(sender, instance, **kwargs)#
Whenever a UserRetirementStatus record is deleted, remove the user’s UserRetirementRequest record IFF the UserRetirementStatus record was still PENDING.
openedx.core.djangoapps.user_api.partition_schemes module#
Provides partition support to the user service.
- class openedx.core.djangoapps.user_api.partition_schemes.NotImplementedPartitionScheme#
Bases:
objectThis “scheme” allows previously-defined schemes to be purged, while giving existing course data definitions a safe entry point to load.
- classmethod get_group_for_user(course_key, user, user_partition, assign=True)#
Returning None is equivalent to saying “This user is not in any groups using this partition scheme”, be sure the scheme you’re removing is compatible with that assumption.
- class openedx.core.djangoapps.user_api.partition_schemes.RandomUserPartitionScheme#
Bases:
objectThis scheme randomly assigns users into the partition’s groups.
- RANDOM = <random.Random object>#
- classmethod get_group_for_user(course_key, user, user_partition, assign=True)#
Returns the group from the specified user position to which the user is assigned. If the user has not yet been assigned, a group will be randomly chosen for them if assign flag is True.
- classmethod key_for_partition(user_partition)#
Returns the key to use to look up and save the user’s group for a given user partition.
- class openedx.core.djangoapps.user_api.partition_schemes.ReturnGroup1PartitionScheme#
Bases:
objectThis scheme is needed to allow verification partitions to be killed, see EDUCATOR-199
- classmethod get_group_for_user(course_key, user, user_partition, assign=True)#
The previous “allow” definition for verification was defined as 1, so return that. Details at openedx/edx-platform#files
openedx.core.djangoapps.user_api.permissions module#
Permissions classes for User-API aware views.
Generates a permission class that grants access if a particular profile field is shared with the requesting user.
openedx.core.djangoapps.user_api.rules module#
Django rules for accounts
openedx.core.djangoapps.user_api.serializers module#
Django REST Framework serializers for the User API application
- class openedx.core.djangoapps.user_api.serializers.CountryTimeZoneSerializer(*args, **kwargs)#
Bases:
SerializerSerializer that generates a list of common time zones for a country
- class openedx.core.djangoapps.user_api.serializers.IDVerificationDetailsSerializer(*args, **kwargs)#
Bases:
Serializer- get_message(obj)#
- get_receipt_id(obj)#
- get_type(obj)#
- class openedx.core.djangoapps.user_api.serializers.RawUserPreferenceSerializer(*args, **kwargs)#
Bases:
ModelSerializerSerializer that generates a raw representation of a user preference.
- class Meta#
Bases:
object- depth = 1#
- fields = ('user', 'key', 'value', 'url')#
- model#
alias of
UserPreference
- class openedx.core.djangoapps.user_api.serializers.ReadOnlyFieldsSerializerMixin#
Bases:
objectMixin for use with Serializers that provides a method get_read_only_fields, which returns a tuple of all read-only fields on the Serializer.
- classmethod get_read_only_fields()#
Return all fields on this Serializer class which are read-only. Expects sub-classes implement Meta.explicit_read_only_fields, which is a tuple declaring read-only fields which were declared explicitly and thus could not be added to the usual cls.Meta.read_only_fields tuple.
- classmethod get_writeable_fields()#
Return all fields on this serializer that are writeable.
- class openedx.core.djangoapps.user_api.serializers.UserPreferenceSerializer(*args, **kwargs)#
Bases:
HyperlinkedModelSerializerSerializer that generates a representation of a UserPreference entity.
- class Meta#
Bases:
object- depth = 1#
- fields = ('user', 'key', 'value', 'url')#
- model#
alias of
UserPreference
- class openedx.core.djangoapps.user_api.serializers.UserSerializer(*args, **kwargs)#
Bases:
HyperlinkedModelSerializerSerializer that generates a representation of a User entity containing a subset of fields
- class Meta#
Bases:
object- fields = ('id', 'url', 'email', 'name', 'username', 'preferences')#
- read_only_fields = ('id', 'email', 'username')#
- ref_name = 'user_api.User'#
- get_name(user)#
Return the name attribute from the user profile object if profile exists else none
- get_preferences(user)#
Returns the set of preferences as a dict for the specified user
openedx.core.djangoapps.user_api.urls module#
Defines the URL routes for this app.
openedx.core.djangoapps.user_api.views module#
HTTP end-points for the User API.
- class openedx.core.djangoapps.user_api.views.CountryTimeZoneListView(**kwargs)#
Bases:
ListAPIViewUse Cases
Retrieves a list of all time zones, by default, or common time zones for country, if given
The country is passed in as its ISO 3166-1 Alpha-2 country code as an optional ‘country_code’ argument. The country code is also case-insensitive.
Example Requests
GET /api/user/v1/preferences/time_zones/
GET /api/user/v1/preferences/time_zones/?country_code=FR
Example GET Response
If the request is successful, an HTTP 200 “OK” response is returned along with a list of time zone dictionaries for all time zones or just for time zones commonly used in a country, if given.
Each time zone dictionary contains the following values.
time_zone: The name of the time zone.
description: The display version of the time zone
- get_queryset()#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- paginator = None#
- serializer_class#
alias of
CountryTimeZoneSerializer
- class openedx.core.djangoapps.user_api.views.ForumRoleUsersListView(**kwargs)#
Bases:
ListAPIViewForum roles are represented by a list of user dicts
- get_queryset()#
Return a list of users with the specified role/course pair
- paginate_by = 10#
- paginate_by_param = 'page_size'#
- permission_classes = (<class 'openedx.core.lib.api.permissions.ApiKeyHeaderPermission'>,)#
- serializer_class#
alias of
UserSerializer
- class openedx.core.djangoapps.user_api.views.PreferenceUsersListView(**kwargs)#
Bases:
ListAPIViewDRF class for listing a user’s preferences
- get_queryset()#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- paginate_by = 10#
- paginate_by_param = 'page_size'#
- permission_classes = (<class 'openedx.core.lib.api.permissions.ApiKeyHeaderPermission'>,)#
- serializer_class#
alias of
UserSerializer
- class openedx.core.djangoapps.user_api.views.UpdateEmailOptInPreference(**kwargs)#
Bases:
APIViewView for updating the email opt in preference.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>,)#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- post(request)#
Post function for updating the email opt in preference.
Allows the modification or creation of the email opt in preference at an organizational level.
- Parameters:
request (Request) –
The request should contain the following POST parameters: * course_id: The slash separated course ID. Used to determine the organization
for this preference setting.
- email_opt_in: “True” or “False” to determine if the user is opting in for emails from
this organization. If the string does not match “True” (case insensitive) it will assume False.
- class openedx.core.djangoapps.user_api.views.UserPreferenceViewSet(**kwargs)#
Bases:
ReadOnlyModelViewSetDRF class for interacting with the UserPreference ORM
- basename = None#
- description = None#
- detail = None#
- filter_backends = (<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>,)#
- filterset_fields = ('key', 'user')#
- name = None#
- paginate_by = 10#
- paginate_by_param = 'page_size'#
- permission_classes = (<class 'openedx.core.lib.api.permissions.ApiKeyHeaderPermission'>,)#
- serializer_class#
alias of
UserPreferenceSerializer
- suffix = None#
- class openedx.core.djangoapps.user_api.views.UserViewSet(**kwargs)#
Bases:
ReadOnlyModelViewSetDRF class for interacting with the User ORM object
- basename = None#
- description = None#
- detail = None#
- name = None#
- paginate_by = 10#
- paginate_by_param = 'page_size'#
- permission_classes = (<class 'openedx.core.lib.api.permissions.ApiKeyHeaderPermission'>,)#
- serializer_class#
alias of
UserSerializer
- suffix = None#