openedx.core.djangoapps.api_admin package#
Subpackages#
Submodules#
openedx.core.djangoapps.api_admin.decorators module#
Decorators for API access management.
- openedx.core.djangoapps.api_admin.decorators.api_access_enabled_or_404(view_func)#
If API access management feature is not enabled, return a 404.
- openedx.core.djangoapps.api_admin.decorators.require_api_access(view_func)#
If the requesting user does not have API access, bounce them to the request form.
openedx.core.djangoapps.api_admin.forms module#
Forms for API management.
- class openedx.core.djangoapps.api_admin.forms.ApiAccessRequestForm(*args, **kwargs)#
Bases:
ModelFormForm to request API access.
- class Meta#
Bases:
object- fields = ('company_name', 'website', 'company_address', 'reason', 'terms_of_service')#
- help_texts = {'company_address': 'The contact address of your organization.', 'company_name': 'The name of your organization.', 'reason': None, 'website': "The URL of your organization's website."}#
- labels = {'company_address': 'Organization Address', 'company_name': 'Organization Name', 'reason': 'Describe what your application does.'}#
- model#
alias of
ApiAccessRequest
- widgets = {'company_address': <django.forms.widgets.Textarea object>}#
- base_fields = {'company_address': <django.forms.fields.CharField object>, 'company_name': <django.forms.fields.CharField object>, 'reason': <django.forms.fields.CharField object>, 'terms_of_service': <django.forms.fields.BooleanField object>, 'website': <django.forms.fields.URLField object>}#
- declared_fields = {'terms_of_service': <django.forms.fields.BooleanField object>}#
- property media#
Return all media required to render the widgets on this form.
- class openedx.core.djangoapps.api_admin.forms.CatalogForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)#
Bases:
ModelFormForm to create a catalog.
- class Meta#
Bases:
object- fields = ('name', 'query', 'viewers')#
- help_texts = {'viewers': 'Comma-separated list of usernames which will be able to view this catalog.'}#
- base_fields = {'name': <django.forms.fields.CharField object>, 'query': <django.forms.fields.CharField object>, 'viewers': <openedx.core.djangoapps.api_admin.forms.ViewersField object>}#
- declared_fields = {'viewers': <openedx.core.djangoapps.api_admin.forms.ViewersField object>}#
- property media#
Return all media required to render the widgets on this form.
- class openedx.core.djangoapps.api_admin.forms.ViewersField(*, required=True, widget=None, label=None, initial=None, help_text='', error_messages=None, show_hidden_initial=False, validators=(), localize=False, disabled=False, label_suffix=None, template_name=None, bound_field_class=None)#
Bases:
FieldCustom form field for a comma-separated list of usernames.
- default_error_messages = {'invalid': 'Enter a comma-separated list of usernames.'}#
- to_python(value)#
Parse out a comma-separated list of usernames.
- validate(value)#
- widget#
alias of
ViewersWidget
openedx.core.djangoapps.api_admin.models module#
Models for API management.
- class openedx.core.djangoapps.api_admin.models.ApiAccessConfig(*args, **kwargs)#
Bases:
ConfigurationModelConfiguration for API management.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- 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#
- 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.api_admin.models.ApiAccessRequest(*args, **kwargs)#
Bases:
TimeStampedModelModel to track API access for a user.
- APPROVED = 'approved'#
- DENIED = 'denied'#
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- PENDING = 'pending'#
- STATUS_CHOICES = (('pending', 'Pending'), ('denied', 'Denied'), ('approved', 'Approved'))#
- classmethod api_access_status(user)#
Returns the user’s API access status, or None if they have not requested access.
- Parameters:
user (User) – The user to check access for.
- Returns:
str or None
- approve()#
Approve this request.
- company_address#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- company_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- contacted#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- deny()#
Deny this request.
- 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)#
- get_status_display(*, field=<django.db.models.fields.CharField: status>)#
- classmethod has_api_access(user)#
Returns whether or not this user has been granted API access.
- Parameters:
user (User) – The user to check access for.
- Returns:
bool
- 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>#
- reason#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod retire_user(user)#
Retires the user’s API acccess request table for GDPR
- Parameters:
user (User) – The user linked to the data to retire in the model.
- Returns:
If the user has a linked data in the model and retirement is successful False: user has no linked data in the model.
- Return type:
True
- site#
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.
- site_id#
- status#
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#
- website#
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.api_admin.models.Catalog(*args, **kwargs)#
Bases:
ModelA (non-Django-managed) model for Catalogs in the course discovery service.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- property attributes#
Return a dictionary representation of this catalog.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name#
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>#
- query#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- save(**kwargs)#
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- viewers#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- openedx.core.djangoapps.api_admin.models.send_decision_email(sender, instance, **kwargs)#
Send decision email after status changed.
- openedx.core.djangoapps.api_admin.models.send_request_email(sender, instance, created, **kwargs)#
Send request email after new record created.
openedx.core.djangoapps.api_admin.urls module#
URLs for API access management.
openedx.core.djangoapps.api_admin.views module#
Views for API management.
- class openedx.core.djangoapps.api_admin.views.ApiRequestStatusView(**kwargs)#
Bases:
ApplicationRegistrationView for confirming our receipt of an API request.
- form_invalid(form)#
If the form is invalid, render the invalid form.
- form_valid(form)#
If the form is valid, save the associated model.
- get(request, form=None)#
If the user has not created an API request, redirect them to the request form. Otherwise, display the status of their API request. We take form as an optional argument so that we can display validation errors correctly on the page.
- get_form(form_class=None)#
Return an instance of the form to be used in this view.
- post(request)#
Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.
- success_url = '/api-admin/status/'#
- class openedx.core.djangoapps.api_admin.views.ApiRequestView(**kwargs)#
Bases:
CreateViewForm view for requesting API access.
- form_class#
alias of
ApiAccessRequestForm
- form_valid(form)#
If the form is valid, save the associated model.
- get(request)#
If the requesting user has already requested API access, redirect them to the client creation page.
- success_url = '/api-admin/status/'#
- template_name = 'api_admin/api_access_request_form.html'#
- class openedx.core.djangoapps.api_admin.views.ApiTosView(**kwargs)#
Bases:
TemplateViewView to show the API Terms of Service.
- template_name = 'api_admin/terms_of_service.html'#
- class openedx.core.djangoapps.api_admin.views.CatalogApiMixin#
Bases:
objectHelpers for work with Catalog API.
- property catalogs_api_url#
Returns the catalogs URL for the catalog API.
- property courses_api_url#
Returns the courses URL for the catalog API.
- get_catalog_api_client(user)#
Returns catalog API client.
- class openedx.core.djangoapps.api_admin.views.CatalogEditView(**kwargs)#
Bases:
CatalogApiMixin,ViewView to edit an individual catalog.
- get(request, catalog_id)#
Display a form to edit this catalog.
- get_context_data(catalog, form)#
Retrieve context data for the template.
- post(request, catalog_id)#
Update or delete this catalog.
- template_name = 'api_admin/catalogs/edit.html'#
- class openedx.core.djangoapps.api_admin.views.CatalogListView(**kwargs)#
Bases:
CatalogApiMixin,ViewView to list existing catalogs and create new ones.
- get(request, username)#
Display a list of a user’s catalogs.
- get_context_data(client, username, form)#
Retrieve context data for the template.
- post(request, username)#
Create a new catalog for a user.
- template = 'api_admin/catalogs/list.html'#
- class openedx.core.djangoapps.api_admin.views.CatalogPreviewView(**kwargs)#
Bases:
CatalogApiMixin,ViewEndpoint to preview courses for a query.
- get(request)#
Return the results of a query against the course catalog API. If no query parameter is given, returns an empty result set.
openedx.core.djangoapps.api_admin.widgets module#
Form widget classes