enterprise.admin package#
Submodules#
enterprise.admin.actions module#
Custom Django Admin actions used in enterprise app.
- enterprise.admin.actions.export_as_csv_action(description='Export selected objects as CSV file', fields=None, header=True)#
Return an export csv action.
- Parameters:
description (string) – action description
fields ([string]) – list of model fields to include
header (bool) – whether or not to output the column names as the first row
- enterprise.admin.actions.refresh_catalog(self, request, queryset)#
Kicks off background running tasks for refreshing catalogs
enterprise.admin.forms module#
Forms to be used in the enterprise djangoapp.
- class enterprise.admin.forms.AdminNotificationForm(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:
ModelForm
Alternate form for AdminNotification.
- class Meta#
Bases:
object
- fields = '__all__'#
- model#
alias of
AdminNotification
- widgets = {'text': <django.forms.widgets.Textarea object>}#
- base_fields = {'admin_notification_filter': <django.forms.models.ModelMultipleChoiceField object>, 'expiration_date': <django.forms.fields.DateField object>, 'is_active': <django.forms.fields.BooleanField object>, 'start_date': <django.forms.fields.DateField object>, 'text': <django.forms.fields.CharField object>, 'title': <django.forms.fields.CharField object>}#
- clean()#
start_date and expiration_date are mandatory.
start_date must always come before the expiration_date.
There must be only one admin notification in a date range.
- declared_fields = {}#
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.BulkCatalogQueryUpdateCommandConfigurationAdmin(model, admin_site)#
Bases:
ConfigurationModelAdmin
Admin form for the BulkCatalogQueryUpdateCommandConfiguration model
- property media#
- class enterprise.admin.forms.EnterpriseCustomerAdminForm(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:
ModelForm
Alternate form for the EnterpriseCustomer admin page.
- class Meta#
Bases:
object
- fields = ('name', 'slug', 'auth_org_id', 'country', 'active', 'customer_type', 'site', 'enable_data_sharing_consent', 'enforce_data_sharing_consent', 'enable_audit_enrollment', 'enable_audit_data_reporting', 'replace_sensitive_sso_username', 'hide_course_original_price', 'enable_portal_code_management_screen', 'enable_portal_subscription_management_screen', 'enable_learner_portal', 'enable_learner_portal_offers', 'enable_portal_learner_credit_management_screen', 'enable_executive_education_2U_fulfillment', 'hide_labor_market_data', 'enable_integrated_customer_learner_portal_search', 'enable_career_engagement_network_on_learner_portal', 'career_engagement_network_message', 'enable_pathways', 'enable_programs', 'enable_demo_data_for_analytics_and_lpr', 'enable_analytics_screen', 'enable_portal_reporting_config_screen', 'enable_portal_saml_configuration_screen', 'enable_portal_lms_configurations_screen', 'enable_universal_link', 'enable_browse_and_request', 'enable_slug_login', 'contact_email', 'default_contract_discount', 'default_language', 'sender_alias', 'reply_to')#
- model#
alias of
EnterpriseCustomer
- base_fields = {'active': <django.forms.fields.BooleanField object>, 'auth_org_id': <django.forms.fields.CharField object>, 'career_engagement_network_message': <django.forms.fields.CharField object>, 'contact_email': <django.forms.fields.EmailField object>, 'country': <django_countries.fields.LazyTypedChoiceField object>, 'customer_type': <django.forms.models.ModelChoiceField object>, 'default_contract_discount': <django.forms.fields.DecimalField object>, 'default_language': <django.forms.fields.TypedChoiceField object>, 'enable_analytics_screen': <django.forms.fields.BooleanField object>, 'enable_audit_data_reporting': <django.forms.fields.BooleanField object>, 'enable_audit_enrollment': <django.forms.fields.BooleanField object>, 'enable_browse_and_request': <django.forms.fields.BooleanField object>, 'enable_career_engagement_network_on_learner_portal': <django.forms.fields.BooleanField object>, 'enable_data_sharing_consent': <django.forms.fields.BooleanField object>, 'enable_demo_data_for_analytics_and_lpr': <django.forms.fields.BooleanField object>, 'enable_executive_education_2U_fulfillment': <django.forms.fields.BooleanField object>, 'enable_integrated_customer_learner_portal_search': <django.forms.fields.BooleanField object>, 'enable_learner_portal': <django.forms.fields.BooleanField object>, 'enable_learner_portal_offers': <django.forms.fields.BooleanField object>, 'enable_pathways': <django.forms.fields.BooleanField object>, 'enable_portal_code_management_screen': <django.forms.fields.BooleanField object>, 'enable_portal_learner_credit_management_screen': <django.forms.fields.BooleanField object>, 'enable_portal_lms_configurations_screen': <django.forms.fields.BooleanField object>, 'enable_portal_reporting_config_screen': <django.forms.fields.BooleanField object>, 'enable_portal_saml_configuration_screen': <django.forms.fields.BooleanField object>, 'enable_portal_subscription_management_screen': <django.forms.fields.BooleanField object>, 'enable_programs': <django.forms.fields.BooleanField object>, 'enable_slug_login': <django.forms.fields.BooleanField object>, 'enable_universal_link': <django.forms.fields.BooleanField object>, 'enforce_data_sharing_consent': <django.forms.fields.TypedChoiceField object>, 'hide_course_original_price': <django.forms.fields.BooleanField object>, 'hide_labor_market_data': <django.forms.fields.BooleanField object>, 'name': <django.forms.fields.CharField object>, 'replace_sensitive_sso_username': <django.forms.fields.BooleanField object>, 'reply_to': <django.forms.fields.EmailField object>, 'sender_alias': <django.forms.fields.CharField object>, 'site': <django.forms.models.ModelChoiceField object>, 'slug': <django.forms.fields.SlugField object>}#
- declared_fields = {}#
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.EnterpriseCustomerCatalogAdminForm(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:
ModelForm
form for EnterpriseCustomerCatalogAdmin class.
- class Meta#
Bases:
object
- fields = '__all__'#
- model#
alias of
EnterpriseCustomerCatalog
- base_fields = {'content_filter': <jsonfield.forms.JSONField object>, 'enabled_course_modes': <jsonfield.forms.JSONField object>, 'enterprise_catalog_query': <django.forms.models.ModelChoiceField object>, 'enterprise_customer': <django.forms.models.ModelChoiceField object>, 'preview_button': <django.forms.fields.Field object>, 'publish_audit_enrollment_urls': <django.forms.fields.BooleanField object>, 'title': <django.forms.fields.CharField object>}#
- declared_fields = {'preview_button': <django.forms.fields.Field object>}#
- static get_catalog_preview_uuid(post_data)#
Return the uuid of the catalog the preview button was clicked on There must be only one preview button in the POST data.
e.g: ‘enterprise_customer_catalogs-0-preview_button’
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.EnterpriseCustomerIdentityProviderAdminForm(*args, **kwargs)#
Bases:
ModelForm
Alternate form for the EnterpriseCustomerIdentityProvider admin page.
This form fetches identity providers from lms third_party_auth app. If third_party_auth app is not avilable it displays provider_id as a CharField.
- class Meta#
Bases:
object
- fields = '__all__'#
- model#
alias of
EnterpriseCustomerIdentityProvider
- base_fields = {'default_provider': <django.forms.fields.BooleanField object>, 'enterprise_customer': <django.forms.models.ModelChoiceField object>, 'provider_id': <django.forms.fields.SlugField object>}#
- clean()#
Final validations of model fields.
Validate that selected site for enterprise customer matches with the selected identity provider’s site.
- declared_fields = {}#
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.EnterpriseCustomerReportingConfigAdminForm(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:
ModelForm
Alternate form for the EnterpriseCustomerReportingConfiguration admin page.
This form uses the PasswordInput widget to obscure passwords as they are being entered by the user.
- class Meta#
Bases:
object
- fields = ('enterprise_customer', 'active', 'data_type', 'report_type', 'delivery_method', 'enable_compression', 'pgp_encryption_key', 'frequency', 'day_of_month', 'day_of_week', 'hour_of_day', 'include_date', 'email', 'decrypted_password', 'sftp_hostname', 'sftp_port', 'sftp_username', 'decrypted_sftp_password', 'sftp_file_path', 'enterprise_customer_catalogs')#
- model#
- widgets = {'decrypted_password': <django.forms.widgets.PasswordInput object>, 'decrypted_sftp_password': <django.forms.widgets.PasswordInput object>}#
- base_fields = {'active': <django.forms.fields.BooleanField object>, 'data_type': <django.forms.fields.TypedChoiceField object>, 'day_of_month': <django.forms.fields.IntegerField object>, 'day_of_week': <django.forms.fields.TypedChoiceField object>, 'decrypted_password': <django.forms.fields.CharField object>, 'decrypted_sftp_password': <django.forms.fields.CharField object>, 'delivery_method': <django.forms.fields.TypedChoiceField object>, 'email': <multi_email_field.forms.MultiEmailField object>, 'enable_compression': <django.forms.fields.BooleanField object>, 'enterprise_customer': <django.forms.models.ModelChoiceField object>, 'enterprise_customer_catalogs': <django.forms.models.ModelMultipleChoiceField object>, 'frequency': <django.forms.fields.TypedChoiceField object>, 'hour_of_day': <django.forms.fields.IntegerField object>, 'include_date': <django.forms.fields.BooleanField object>, 'pgp_encryption_key': <django.forms.fields.CharField object>, 'report_type': <django.forms.fields.TypedChoiceField object>, 'sftp_file_path': <django.forms.fields.CharField object>, 'sftp_hostname': <django.forms.fields.CharField object>, 'sftp_port': <django.forms.fields.IntegerField object>, 'sftp_username': <django.forms.fields.CharField object>}#
- clean()#
Override of clean method to perform additional validation
- declared_fields = {'enterprise_customer_catalogs': <django.forms.models.ModelMultipleChoiceField object>}#
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.EnterpriseFeatureUserRoleAssignmentForm(*args, **kwargs)#
Bases:
UserRoleAssignmentAdminForm
Form for EnterpriseFeatureUserRoleAssignments.
- class Meta#
Bases:
object
- fields = ['user', 'role']#
- model#
alias of
EnterpriseFeatureUserRoleAssignment
- base_fields = {'role': <django.forms.models.ModelChoiceField object>, 'user': <edx_rbac.fields.UserFromEmailField object>}#
- declared_fields = {'user': <edx_rbac.fields.UserFromEmailField object>}#
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.ManageLearnersDataSharingConsentForm(*args, **kwargs)#
Bases:
Form
Form to request DSC from a learner.
- class Fields#
Bases:
object
Namespace class for field names.
- COURSE = 'course'#
- EMAIL_OR_USERNAME = 'email_or_username'#
- base_fields = {'course': <django.forms.fields.CharField object>, 'email_or_username': <django.forms.fields.CharField object>}#
- clean_course()#
Verify course ID has an associated course in LMS.
- clean_email_or_username()#
Verify email_or_username has associated user in our database.
- declared_fields = {'course': <django.forms.fields.CharField object>, 'email_or_username': <django.forms.fields.CharField object>}#
- is_course_in_catalog(course_id)#
Check whether course exists in enterprise customer catalog.
- is_user_linked(email)#
Check whether user is linked to the enterprise customer or not.
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.ManageLearnersForm(*args, **kwargs)#
Bases:
Form
Form to manage learner additions.
- class CsvColumns#
Bases:
object
Namespace class for CSV column names.
- COURSE_ID = 'course_id'#
- EMAIL = 'email'#
- class Fields#
Bases:
object
Namespace class for field names.
- BULK_UPLOAD = 'bulk_upload_csv'#
- COURSE = 'course'#
- COURSE_MODE = 'course_mode'#
- DISCOUNT = 'discount'#
- EMAIL_OR_USERNAME = 'email_or_username'#
- GENERAL_ERRORS = '__all__'#
- MODE = 'mode'#
- NOTIFY = 'notify_on_enrollment'#
- REASON = 'reason'#
- SALES_FORCE_ID = 'sales_force_id'#
- class Modes#
Bases:
object
Namespace class for form modes.
- MODE_BULK = 'bulk'#
- MODE_SINGULAR = 'singular'#
- class NotificationTypes#
Bases:
object
Namespace class for notification types
- BY_EMAIL = 'by_email'#
- DEFAULT = 'by_email'#
- NO_NOTIFICATION = 'do_not_notify'#
- base_fields = {'bulk_upload_csv': <django.forms.fields.FileField object>, 'course': <django.forms.fields.CharField object>, 'course_mode': <django.forms.fields.ChoiceField object>, 'discount': <django.forms.fields.DecimalField object>, 'email_or_username': <django.forms.fields.CharField object>, 'notify_on_enrollment': <django.forms.fields.ChoiceField object>, 'reason': <django.forms.fields.CharField object>, 'sales_force_id': <django.forms.fields.CharField object>}#
- clean()#
Clean fields that depend on each other.
In this case, the form can be used to link single user or bulk link multiple users. These are mutually exclusive modes, so this method checks that only one field is passed.
- clean_course()#
Verify course ID and retrieve course details.
- clean_discount()#
Verify that discount value should be from 0 to 100.
- clean_email_or_username()#
Clean email form field
- Returns:
the cleaned value, converted to an email address (or an empty string)
- Return type:
- clean_notify()#
Clean the notify_on_enrollment field.
- clean_reason()#
Clean the reason for enrollment field
- declared_fields = {'bulk_upload_csv': <django.forms.fields.FileField object>, 'course': <django.forms.fields.CharField object>, 'course_mode': <django.forms.fields.ChoiceField object>, 'discount': <django.forms.fields.DecimalField object>, 'email_or_username': <django.forms.fields.CharField object>, 'notify_on_enrollment': <django.forms.fields.ChoiceField object>, 'reason': <django.forms.fields.CharField object>, 'sales_force_id': <django.forms.fields.CharField object>}#
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.SystemWideEnterpriseUserRoleAssignmentForm(*args, **kwargs)#
Bases:
UserRoleAssignmentAdminForm
Form for SystemWideEnterpriseUserRoleAssignments.
- class Meta#
Bases:
object
- fields = ['user', 'role', 'enterprise_customer', 'applies_to_all_contexts']#
- model#
- base_fields = {'applies_to_all_contexts': <django.forms.fields.BooleanField object>, 'enterprise_customer': <django.forms.models.ModelChoiceField object>, 'role': <django.forms.models.ModelChoiceField object>, 'user': <edx_rbac.fields.UserFromEmailField object>}#
- clean()#
Ensure that the form’s enterprise customer value defaults to the first active, linked enterprise customer by the provided user
- declared_fields = {'user': <edx_rbac.fields.UserFromEmailField object>}#
- property media#
Return all media required to render the widgets on this form.
- class enterprise.admin.forms.TransmitEnterpriseCoursesForm(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, field_order=None, use_required_attribute=None, renderer=None)#
Bases:
Form
Form to transmit courses metadata for enterprise customers.
- base_fields = {'channel_worker_username': <django.forms.fields.CharField object>}#
- clean_channel_worker_username()#
Clean enterprise channel worker user form field
- Returns:
the cleaned value of channel user username for transmitting courses metadata.
- Return type:
- declared_fields = {'channel_worker_username': <django.forms.fields.CharField object>}#
- property media#
Return all media required to render the widgets on this form.
enterprise.admin.paginator module#
Custom paginator to implement smart pagination.
- class enterprise.admin.paginator.CustomPaginator(object_list, per_page, orphans=0, allow_empty_first_page=True)#
Bases:
Paginator
Adopted from django/core/paginator so as to implement smart links pagination in custom views.
- property page_range#
We have customized the getter so that it can return the value of the page_range property instead of always calculating the result.
enterprise.admin.utils module#
Admin utilities.
- class enterprise.admin.utils.UrlNames#
Bases:
object
Collection on URL names used in admin
- MANAGE_LEARNERS = 'enterprise_manage_learners'#
- MANAGE_LEARNERS_DSC = 'enterprise_manage_learners_data_sharing_consent'#
- PREVIEW_EMAIL_TEMPLATE = 'enterprise_preview_email_template'#
- PREVIEW_QUERY_RESULT = 'enterprise_preview_query_result'#
- SETUP_AUTH_ORG_ID = 'enterprise_setup_auth_org_id'#
- TRANSMIT_COURSES_METADATA = 'enterprise_transmit_courses_metadata'#
- URL_PREFIX = 'enterprise_'#
- enterprise.admin.utils.email_or_username__to__email(email_or_username)#
Convert email_or_username to email.
- Returns:
- If email_or_username was a username returns user’s email, otherwise assumes it was an email and returns
as is.
- Return type:
- enterprise.admin.utils.paginated_list(object_list, page, page_size=25)#
Returns paginated list.
- Parameters:
Adopted from django/contrib/admin/templatetags/admin_list.py django/django
- enterprise.admin.utils.parse_csv(file_stream, expected_columns=None)#
Parse csv file and return a stream of dictionaries representing each row.
First line of CSV file must contain column headers.
- Parameters:
file_stream – input file
expected_columns (set[unicode]) – columns that are expected to be present
- Yields:
dict – CSV line parsed into a dictionary.
- enterprise.admin.utils.split_usernames_and_emails(email_field)#
Split the contents of the email field into a list.
In some cases, a user could enter a comma-separated value inline in the Manage Learners form. We should check to see if that’s the case, and provide a list of email addresses or usernames if it is.
- enterprise.admin.utils.validate_csv(file_stream, expected_columns=None)#
Validate csv file for encoding and expected header.
- Parameters:
file_stream – input file
expected_columns – list of column names that are expected to be present in csv
- Returns:
an iterable for csv datat if csv passes the validation
- Return type:
reader
- Raises:
ValidationError –
enterprise.admin.views module#
Custom Django Admin views used in enterprise app.
- class enterprise.admin.views.BaseEnterpriseCustomerView(**kwargs)#
Bases:
View
Base class for Enterprise Customer views.
- get_form_view(request, customer_uuid, additional_context=None)#
render the form with appropriate context.
- template = None#
- class enterprise.admin.views.CatalogQueryPreviewView(**kwargs)#
Bases:
APIView
Renders a search/all response from Discovery for a particular catalog query.
- get(request, catalog_query_id)#
Render the response for a particular catalog query.
- static get_response_from_discovery(request, catalog_query)#
POST a query to Discovery’s search/all endpoint and return the results.
- class enterprise.admin.views.EnterpriseCustomerManageLearnerDataSharingConsentView(**kwargs)#
Bases:
BaseEnterpriseCustomerView
Manage Learners Data Sharing Consent View.
Allows to request the DSC from a learner for a specific course.
- class ContextParameters#
Bases:
object
Namespace-style class for custom context parameters.
- ENTERPRISE_CUSTOMER = 'enterprise_customer'#
- MANAGE_LEARNERS_DSC_FORM = 'manage_learners_data_sharing_consent_form'#
- get(request, customer_uuid)#
Handle GET request - render “Request a DSC from Learner” form.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- Returns:
HttpResponse
- Return type:
django.http.response.HttpResponse
- post(request, customer_uuid)#
Handle POST request - handle form submissions.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- template = 'enterprise/admin/clear_learners_data_sharing_consent.html'#
- class enterprise.admin.views.EnterpriseCustomerManageLearnersView(**kwargs)#
Bases:
BaseEnterpriseCustomerView
Manage Learners view.
Lists learners linked to chosen Enterprise Customer and allows adding and deleting them.
- class ContextParameters#
Bases:
object
Namespace-style class for custom context parameters.
- ENROLLMENT_URL = 'ENROLLMENT_API_ROOT_URL'#
- ENTERPRISE_CUSTOMER = 'enterprise_customer'#
- LEARNERS = 'learners'#
- MANAGE_LEARNERS_FORM = 'manage_learners_form'#
- PENDING_LEARNERS = 'pending_learners'#
- SEARCH_KEYWORD = 'search_keyword'#
- delete(request, customer_uuid)#
Handle DELETE request - handle unlinking learner.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- Returns:
HttpResponse
- Return type:
django.http.response.HttpResponse
- get(request, customer_uuid)#
Handle GET request - render linked learners list and “Link learner” form.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- Returns:
HttpResponse
- Return type:
django.http.response.HttpResponse
- get_enterprise_customer_user_queryset(request, search_keyword, customer_uuid, page_size=25)#
Get the list of EnterpriseCustomerUsers we want to render.
- Parameters:
request (HttpRequest) – HTTP Request instance.
search_keyword (str) – The keyword to search for in users’ email addresses and usernames.
customer_uuid (str) – A unique identifier to filter down to only users linked to a
EnterpriseCustomer. (particular) –
page_size (int) – Number of learners displayed in each paginated set.
- classmethod get_failed_enrollment_message(users, enrolled_in)#
Create message for the users who were not able to be enrolled in a course.
- Parameters:
users – An iterable of users who were not successfully enrolled
enrolled_in (str) – A string identifier for the course with which enrollment was attempted
Returns: tuple: A 2-tuple containing a message type and message text
- classmethod get_pending_enrollment_message(pending_users, enrolled_in)#
Create message for the users who were enrolled in a course.
- get_pending_users_queryset(search_keyword, customer_uuid)#
Get the list of PendingEnterpriseCustomerUsers we want to render.
- get_search_keyword(request)#
Retrieve the search querystring from the GET parameters.
- classmethod get_success_enrollment_message(users, enrolled_in)#
Create message for the users who were enrolled in a course.
- post(request, customer_uuid)#
Handle POST request - handle form submissions.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- Returns:
HttpResponse
- Return type:
django.http.response.HttpResponse
- classmethod send_messages(http_request, message_requests)#
Deduplicate any outgoing message requests, and send the remainder.
- Parameters:
http_request – The HTTP request in whose response we want to embed the messages
message_requests – A list of undeduplicated messages in the form of tuples of message type and text- for example, (‘error’, ‘Something went wrong’)
- template = 'enterprise/admin/manage_learners.html'#
- class enterprise.admin.views.EnterpriseCustomerSetupAuthOrgIDView(**kwargs)#
Bases:
BaseEnterpriseCustomerView
Setup Auth org id View.
This action will configure SSO to GetSmarter using edX credentials via Auth0.
- get(request, customer_uuid)#
Handle GET request - render “Setup Auth org id” form.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- Returns:
HttpResponse
- Return type:
django.http.response.HttpResponse
- post(request, customer_uuid)#
Handle POST request - handle form submissions.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- template = 'enterprise/admin/setup_auth_org_id.html'#
- class enterprise.admin.views.EnterpriseCustomerTransmitCoursesView(**kwargs)#
Bases:
BaseEnterpriseCustomerView
Transmit courses view.
Allows transmitting of courses metadata for provided enterprise.
- class ContextParameters#
Bases:
object
Namespace-style class for custom context parameters.
- ENTERPRISE_CUSTOMER = 'enterprise_customer'#
- TRANSMIT_COURSES_METADATA_FORM = 'transmit_courses_metadata_form'#
- get(request, customer_uuid)#
Handle GET request - render “Transmit courses metadata” form.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- Returns:
HttpResponse
- Return type:
django.http.response.HttpResponse
- post(request, customer_uuid)#
Handle POST request - handle form submissions.
- Parameters:
request (django.http.request.HttpRequest) – Request instance
customer_uuid (str) – Enterprise Customer UUID
- template = 'enterprise/admin/transmit_courses_metadata.html'#
- class enterprise.admin.views.TemplatePreviewView(**kwargs)#
Bases:
View
Renders a given NotificationTemplate object to HTML for online viewing.
- get(request, template_id, view_type)#
Render the given template with the stock data.
- static get_user_name(request)#
Get a human-readable name for the user.
- view_type_contexts = {'course': {'enrolled_in': {'name': 'OpenEdX Demo Course', 'start': datetime.datetime(2016, 1, 1, 0, 0), 'type': 'course', 'url': 'http://example.com/courses/edx-demo-course'}, 'organization_name': 'OpenEdX'}, 'program': {'enrolled_in': {'branding': 'MicroMasters', 'name': 'OpenEdX Demo Program', 'start': datetime.datetime(2016, 1, 1, 0, 0), 'type': 'program', 'url': 'http://example.com/programs/edx-demo-program'}, 'organization_name': 'OpenEdX'}}#
enterprise.admin.widgets module#
Widgets to be used in the enterprise djangoapp.
Module contents#
Django admin integration for enterprise app.
- class enterprise.admin.AdminNotificationAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin for AdminNotification model.
- filter_horizontal = ('admin_notification_filter',)#
- form#
alias of
AdminNotificationForm
- list_display = ('id', 'title', 'text', 'is_active', 'start_date', 'expiration_date', 'created', 'modified')#
- property media#
- model#
alias of
AdminNotification
- class enterprise.admin.AdminNotificationFilterAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin for models.AdminNotificationFilter model.
- list_display = ('id', 'filter', 'created', 'modified')#
- property media#
- model#
alias of
AdminNotificationFilter
- class enterprise.admin.AdminNotificationReadAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin for AdminNotificationRead model.
- list_display = ('id', 'enterprise_customer_user', 'admin_notification', 'is_read', 'created', 'modified')#
- property media#
- model#
alias of
AdminNotificationRead
- class enterprise.admin.BigTableMysqlPaginator(object_list, per_page, orphans=0, allow_empty_first_page=True)#
Bases:
Paginator
A paginator that uses INFORMATION_SCHEMA.TABLES to estimate the total number of rows in a table.
- ARBITRARILY_LARGE_NUMBER = 10000000#
- property count#
Returns the number of items in the object list (possibly an estimate).
- class enterprise.admin.ChatGPTResponseAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin for ChatGPTResponse model.
- list_display = ('uuid', 'prompt_type', 'enterprise_customer', 'prompt_hash', 'created')#
- list_filter = ('prompt_type',)#
- property media#
- model#
alias of
ChatGPTResponse
- readonly_fields = ('prompt_type', 'prompt', 'response', 'prompt_hash', 'created', 'modified')#
- class enterprise.admin.EnrollmentNotificationEmailTemplateAdmin(model, admin_site)#
Bases:
DjangoObjectActions
,ModelAdmin
Django admin for EnrollmentNotificationEmailTemplate model
- class Meta#
Bases:
object
- model#
alias of
EnrollmentNotificationEmailTemplate
- change_actions = ('preview_as_course', 'preview_as_program')#
- get_urls()#
Returns the additional urls used by the custom object tools.
- property media#
- preview(obj, preview_type)#
Object tool handler method - redirects to “Preview” view
- preview_as_course(request, obj)#
Redirect to preview the HTML template in the context of a course.
- preview_as_program(request, obj)#
Redirect to preview the HTML template in the context of a program.
- class enterprise.admin.EnterpriseCatalogQueryAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for EnterpriseCatalogQuery.
- class Meta#
Bases:
object
- model#
alias of
EnterpriseCatalogQuery
- discovery_query_url(obj)#
Return discovery url for preview.
- fields = ('uuid', 'title', 'discovery_query_url', 'content_filter')#
- get_urls()#
Returns the additional urls used by the custom object tools.
- has_delete_permission(request, obj=None)#
Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the obj model instance. If obj is None, this should return True if the given request has permission to delete any object of the given type.
- list_display = ('title', 'discovery_query_url')#
- property media#
- readonly_fields = ('discovery_query_url', 'uuid')#
- class enterprise.admin.EnterpriseCourseEnrollmentAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for EnterpriseCourseEnrollment
- class Meta#
Bases:
object
- model#
alias of
EnterpriseCourseEnrollment
- change_list_template = 'enterprise/admin/enterprise_course_enrollments_list.html'#
- changelist_view(request, extra_context=None)#
Override to conditionally show the button.
- get_urls()#
Append Enrollment Attribute Override view url with default urls
- has_add_permission(request)#
Disable add permission for EnterpriseCourseEnrollment.
- has_delete_permission(request, obj=None)#
Disable deletion for EnterpriseCourseEnrollment.
- license_uuid(obj)#
Return the subscription license UUID (if any exists) associated with this enrollment.
- list_display = ('enterprise_customer_user', 'course_id', 'saved_for_later', 'unenrolled_at')#
- property media#
- readonly_fields = ('enterprise_customer_user', 'course_id', 'saved_for_later', 'license_uuid')#
- search_fields = ('enterprise_customer_user__user_id', 'course_id')#
- class enterprise.admin.EnterpriseCustomerAdmin(model, admin_site)#
Bases:
DjangoObjectActions
,SimpleHistoryAdmin
Django admin model for EnterpriseCustomer.
- EXPORT_AS_CSV_FIELDS = ['name', 'active', 'site', 'uuid', 'identity_provider']#
- class Meta#
Bases:
object
- model#
alias of
EnterpriseCustomer
- actions = [<function export_as_csv_action.<locals>.export_as_csv>]#
- change_actions = ('setup_auth_org_id', 'manage_learners', 'manage_learners_data_sharing_consent', 'transmit_courses_metadata')#
- change_view(request, object_id, form_url='', extra_context=None)#
- enable_dsc(instance)#
Return True if data sharing consent is enabled for EnterpriseCustomer.
- Parameters:
instance (enterprise.models.EnterpriseCustomer) – EnterpriseCustomer model instance
- fieldsets = (('Enterprise info', {'fields': ('name', 'active', 'slug', 'auth_org_id', 'country')}), ('Subsidy management screens ', {'fields': ('enable_portal_learner_credit_management_screen', 'enable_portal_subscription_management_screen', 'enable_portal_code_management_screen'), 'description': "Select the check boxes below to enable specific subsidy management screens on the organization's administrator portal. If an option is left unchecked, the customer administrator will not see the screen in their portal and will not be able to apply the associated configurations via self-service."}), ('Subsidy settings', {'fields': ('enable_browse_and_request', 'enable_universal_link'), 'description': 'Select the check boxes below to enable specific subsidy management settings for the administrator portal for subscription and codes customers. These should not be selected for customers that only have learner credit.'}), ('Data sharing consent', {'fields': ('enable_data_sharing_consent', 'enforce_data_sharing_consent')}), ('Email and language ', {'fields': ('contact_email', 'reply_to', 'sender_alias', 'default_language', 'hide_labor_market_data')}), ('Reporting', {'fields': ('enable_portal_reporting_config_screen',)}), ('Integration and learning platform settings', {'fields': ('enable_portal_lms_configurations_screen', 'enable_portal_saml_configuration_screen', 'enable_slug_login', 'replace_sensitive_sso_username', 'hide_course_original_price', 'enable_generation_of_api_credentials')}), ('Recommended default settings for all enterprise customers', {'fields': ('site', 'customer_type', 'enable_learner_portal', 'enable_integrated_customer_learner_portal_search', 'enable_analytics_screen', 'enable_audit_enrollment', 'enable_audit_data_reporting', 'enable_learner_portal_offers', 'enable_executive_education_2U_fulfillment', 'enable_career_engagement_network_on_learner_portal', 'career_engagement_network_message', 'enable_pathways', 'enable_programs', 'enable_demo_data_for_analytics_and_lpr', 'enable_academies'), 'description': 'The following default settings should be the same for the majority of enterprise customers, and are either rarely used, unlikely to be sold, or unlikely to be changed from the default.'}))#
- form#
alias of
EnterpriseCustomerAdminForm
- get_change_actions(*args, **kwargs)#
Buttons that appear at the top of the “Change Enterprise Customer” page.
Due to a known deficiency in the upstream django_object_actions library, we must STILL define change_actions above with all possible values.
- get_form(request, obj=None, change=False, **kwargs)#
Retrieve the appropriate form to use, saving the request user into the form for use in loading catalog details
- get_search_results(request, queryset, search_term)#
Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.
- get_urls()#
Returns the additional urls used by the custom object tools.
- has_identity_provider(instance)#
Return True if EnterpriseCustomer has related identity provider.
- Parameters:
instance (enterprise.models.EnterpriseCustomer) – EnterpriseCustomer model instance
- has_logo(instance)#
Return True if EnterpriseCustomer has a logo.
- Parameters:
instance (enterprise.models.EnterpriseCustomer) – EnterpriseCustomer model instance
- inlines = [<class 'enterprise.admin.EnterpriseCustomerBrandingConfigurationInline'>, <class 'enterprise.admin.EnterpriseCustomerIdentityProviderInline'>, <class 'enterprise.admin.EnterpriseCustomerCatalogInline'>, <class 'enterprise.admin.PendingEnterpriseCustomerAdminUserInline'>]#
- list_display = ('name', 'slug', 'customer_type', 'site', 'country', 'active', 'has_logo', 'enable_dsc', 'has_identity_provider', 'uuid')#
- list_filter = ('active',)#
- manage_learners(request, obj)#
Object tool handler method - redirects to “Manage Learners” view
- manage_learners_data_sharing_consent(request, obj)#
Object tool handler method - redirects to “Clear Learners Data Sharing Consent” view
- property media#
- ordering = ('name',)#
- search_fields = ('name', 'uuid')#
- setup_auth_org_id(request, obj)#
Object tool handler method - redirects to Setup Auth org id view.
- transmit_courses_metadata(request, obj)#
Object tool handler method - redirects to Transmit Courses Metadata view.
- class enterprise.admin.EnterpriseCustomerBrandingConfigurationInline(parent_model, admin_site)#
Bases:
StackedInline
Django admin model for EnterpriseCustomerBrandingConfiguration.
The admin interface has the ability to edit models on the same page as a parent model. These are called inlines. https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.StackedInline
- can_delete = False#
- property media#
- model#
- class enterprise.admin.EnterpriseCustomerCatalogAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for EnterpriseCustomerCatalog.
- class Meta#
Bases:
object
- model#
alias of
EnterpriseCustomerCatalog
- actions = [<function refresh_catalog>]#
- autocomplete_fields = ['enterprise_customer']#
- fields = ('title', 'enterprise_customer', 'enterprise_catalog_query', 'content_filter', 'enabled_course_modes', 'publish_audit_enrollment_urls')#
- get_actions(request)#
Disallow the delete selected action as that does not send a DELETE request to enterprise-catalog
- get_form(request, obj=None, change=False, **kwargs)#
Return a Form class for use in the admin add view. This is used by add_view and change_view.
- list_display = ('uuid_nowrap', 'enterprise_customer', 'title', 'preview_catalog_url')#
- property media#
- ordering = ('enterprise_customer__name', 'title')#
- preview_catalog_url(obj)#
Return enterprise catalog url for preview.
- readonly_fields = ('preview_catalog_url',)#
- search_fields = ('uuid', 'title', 'enterprise_customer__name', 'enterprise_customer__uuid')#
- uuid_nowrap(obj)#
Inject html for disabling wrap for uuid
- class enterprise.admin.EnterpriseCustomerCatalogInline(parent_model, admin_site)#
Bases:
TabularInline
Django admin model for EnterpriseCustomerCatalog. The admin interface has the ability to edit models on the same page as a parent model. These are called inlines. https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.StackedInline
- can_delete = False#
- extra = 0#
- form#
alias of
EnterpriseCustomerCatalogAdminForm
- get_formset(request, obj=None, **kwargs)#
Return a BaseInlineFormSet class for use in admin add/change views.
- property media#
- model#
alias of
EnterpriseCustomerCatalog
- class enterprise.admin.EnterpriseCustomerIdentityProviderInline(parent_model, admin_site)#
Bases:
StackedInline
Django admin model for EnterpriseCustomerIdentityProvider.
The admin interface has the ability to edit models on the same page as a parent model. These are called inlines. https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.StackedInline
- extra = 0#
- form#
- property media#
- model#
alias of
EnterpriseCustomerIdentityProvider
- class enterprise.admin.EnterpriseCustomerInviteKeyAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for EnterpriseCustomerInviteKey.
- class Meta#
Bases:
object
- model#
alias of
EnterpriseCustomerInviteKey
- fields = ('enterprise_customer', 'usage_count', 'usage_limit', 'expiration_date', 'is_active')#
- get_readonly_fields(request, obj=None)#
Hook for specifying custom readonly fields.
- list_display = ('uuid', 'enterprise_customer_id', 'usage_limit', 'expiration_date', 'is_active')#
- list_filter = ('is_active',)#
- property media#
- readonly_fields = ('uuid', 'usage_count')#
- search_fields = ('uuid__startswith', 'enterprise_customer__name__startswith')#
- class enterprise.admin.EnterpriseCustomerReportingConfigurationAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for EnterpriseCustomerReportingConfiguration.
- autocomplete_fields = ['enterprise_customer']#
- form#
- get_fields(request, obj=None)#
Return the fields that should be displayed on the admin form.
- list_display = ('enterprise_customer', 'active', 'delivery_method', 'frequency', 'data_type', 'report_type')#
- list_filter = ('active',)#
- property media#
- ordering = ('enterprise_customer__name',)#
- search_fields = ('enterprise_customer__name', 'email')#
- class enterprise.admin.EnterpriseCustomerSsoConfigurationAdmin(model, admin_site)#
Bases:
DjangoObjectActions
,ModelAdmin
Django admin for models.EnterpriseCustomerSsoConfigurationAdmin model.
- change_actions = ['mark_configured']#
- list_display = ('uuid', 'enterprise_customer', 'active', 'identity_provider', 'created', 'configured_at')#
- mark_configured(request, obj)#
Object tool handler method - marks the config as configured.
- property media#
- model#
alias of
EnterpriseCustomerSsoConfiguration
- class enterprise.admin.EnterpriseCustomerTypeAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for EnterpriseCustomerType.
- class Meta#
Bases:
object
- model#
alias of
EnterpriseCustomerType
- fields = ('name',)#
- list_display = ('name',)#
- property media#
- search_fields = ('name',)#
- class enterprise.admin.EnterpriseCustomerUserAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for EnterpriseCustomerUser.
- class Meta#
Bases:
object
- model#
alias of
EnterpriseCustomerUser
- enterprise_enrollments(enterprise_customer_user)#
Return a string representing a given EnterpriseCustomerUser’s enterprise course enrollments
- Parameters:
enterprise_customer_user – The instance of EnterpriseCustomerUser being rendered with this admin form.
- fields = ('user_id', 'enterprise_customer', 'user_email', 'username', 'created', 'enterprise_enrollments', 'other_enrollments', 'invite_key', 'active', 'should_inactivate_other_customers')#
- get_enrolled_course_string(course_ids)#
Get an HTML string representing the courses the user is enrolled in.
- get_enterprise_customer(obj)#
Returns the name of enterprise customer linked with the enterprise customer user.
- get_readonly_fields(request, obj=None)#
Make all fields readonly when editing existing model.
- get_search_results(request, queryset, search_term)#
Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.
- list_display = ('username', 'user_email', 'get_enterprise_customer')#
- property media#
- other_enrollments(enterprise_customer_user)#
Return a string representing a given EnterpriseCustomerUser’s non-enterprise course enrollments
- Parameters:
enterprise_customer_user – The instance of EnterpriseCustomerUser being rendered with this admin form.
- readonly_fields = ('user_email', 'username', 'created', 'enterprise_enrollments', 'other_enrollments')#
- search_fields = ('user_id', 'user_email')#
- class enterprise.admin.EnterpriseFeatureUserRoleAssignmentAdmin(model, admin_site)#
Bases:
UserRoleAssignmentAdmin
Django admin model for EnterpriseFeatureUserRoleAssignment.
- class Meta#
Bases:
object
- model#
alias of
EnterpriseFeatureUserRoleAssignment
- form#
- property media#
- class enterprise.admin.EnterpriseGroupAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin for EnterpriseGroup model.
- count(obj)#
Return the number of members in a group
- list_display = ('uuid', 'enterprise_customer', 'applies_to_all_contexts')#
- list_filter = ('applies_to_all_contexts',)#
- property media#
- members(obj)#
Return the non-deleted members of a group
- model#
alias of
EnterpriseGroup
- readonly_fields = ('count', 'members')#
- search_fields = ('uuid', 'name', 'enterprise_customer__name', 'enterprise_customer__uuid')#
- class enterprise.admin.EnterpriseGroupMembershipAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin for EnterpriseGroupMembership model.
- autocomplete_fields = ('group', 'enterprise_customer_user', 'pending_enterprise_customer_user')#
- list_display = ('group', 'membership_user')#
- property media#
- model#
alias of
EnterpriseGroupMembership
- search_fields = ('uuid', 'group__enterprise_customer_user', 'enterprise_customer_user', 'pending_enterprise_customer_user')#
- class enterprise.admin.PendingEnrollmentAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for PendingEnrollment
- class Meta#
Bases:
object
- model#
alias of
PendingEnrollment
- has_add_permission(request)#
Disable add permission for PendingEnrollment.
- has_delete_permission(request, obj=None)#
Disable deletion for PendingEnrollment.
- list_display = ('user', 'course_id', 'course_mode')#
- property media#
- readonly_fields = ('user', 'course_id', 'course_mode')#
- search_fields = ('user__user_email', 'course_id')#
- class enterprise.admin.PendingEnterpriseCustomerAdminUserAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for PendingEnterpriseCustomerAdminUser
- class Meta#
Bases:
object
- model#
alias of
PendingEnterpriseCustomerAdminUser
- fields = ('user_email', 'enterprise_customer', 'get_admin_registration_url')#
- get_admin_registration_url(obj)#
Formats the
admin_registration_url
model property as an HTML link.
- get_enterprise_customer(obj)#
Returns the name of the associated EnterpriseCustomer.
- list_display = ('user_email', 'get_enterprise_customer', 'get_admin_registration_url')#
- property media#
- readonly_fields = ('get_admin_registration_url',)#
- search_fields = ('user_email', 'enterprise_customer__name')#
- class enterprise.admin.PendingEnterpriseCustomerAdminUserInline(parent_model, admin_site)#
Bases:
TabularInline
Django admin inline model for PendingEnterpriseCustomerAdminUser.
- extra = 0#
- fieldsets = ((None, {'fields': ('user_email', 'get_admin_registration_url')}),)#
- get_admin_registration_url(obj)#
Formats the
admin_registration_url
model property as an HTML link.
- property media#
- model#
alias of
PendingEnterpriseCustomerAdminUser
- readonly_fields = ('get_admin_registration_url',)#
- class enterprise.admin.PendingEnterpriseCustomerUserAdmin(model, admin_site)#
Bases:
ModelAdmin
Django admin model for PendingEnterpriseCustomerUser
- class Meta#
Bases:
object
- model#
alias of
PendingEnterpriseCustomerUser
- fields = ('user_email', 'enterprise_customer', 'created')#
- property media#
- readonly_fields = ('user_email', 'enterprise_customer', 'created')#
- search_fields = ('user_email', 'id')#
- class enterprise.admin.SystemWideEnterpriseUserRoleAssignmentAdmin(model, admin_site)#
Bases:
UserRoleAssignmentAdmin
Django admin model for SystemWideEnterpriseUserRoleAssignment.
- fields = ('user', 'role', 'enterprise_customer', 'applies_to_all_contexts')#
- form#
- list_display = ('user', 'role', 'enterprise_customer', 'applies_to_all_contexts')#
- list_per_page = 25#
- property media#
- paginator#
alias of
BigTableMysqlPaginator
- search_fields = ('user__email', 'role__name', 'enterprise_customer__name')#
- show_full_result_count = False#