enterprise.management.commands package#

Submodules#

enterprise.management.commands.add_exec_ed_exclusion_to_catalogs module#

Django management command to add Exec Ed exclusion flag to catalogs

class enterprise.management.commands.add_exec_ed_exclusion_to_catalogs.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Enumerate the catalog filters and add course_type exclusions where required

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

enterprise.management.commands.backfill_learner_role_assignments module#

Management command for assigning enterprise_learner roles to existing linked enterprise users that are missing them.

class enterprise.management.commands.backfill_learner_role_assignments.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Management command for assigning enterprise_learner roles to existing enterprise users.

Example usage:

$ ./manage.py backfill_learner_role_assignments

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

backfill_learner_role_assignments(options)#

Assigns enterprise_learner role to users.

handle(*args, **options)#

Entry point for management command execution.

help = 'Assigns enterprise_learner role to linked enterprise users missing them.'#

enterprise.management.commands.bulk_update_catalog_query_id module#

Django management command for bulk updating EnterpriseCustomerCatalog record’s EnterpriseCatalogQuery’s.

class enterprise.management.commands.bulk_update_catalog_query_id.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Takes a new and old Enterprise Catalog Query ID, find all most recent records within the historical Enterprise Catalog table where enterprise catalog query ID is the old ID provided and updates the corresponding Enterprise Catalog table entries with the new ID.

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

get_args_from_database()#

Returns an options dictionary from the current BulkCatalogQueryUpdateCommandConfiguration model.

handle(*args, **options)#

Entry point for management command execution.

help = "Updates specified EnterpriseCatalog's enterprise catalog query ID records with a provided new ID"#

enterprise.management.commands.compare_discovery_and_enterprise_catalogs module#

Django management command to explore Exec Ed inclusion flag migration

class enterprise.management.commands.compare_discovery_and_enterprise_catalogs.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Enumerate the catalog filters and log information about how we might migrate them.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

enterprise.management.commands.create_enterprise_course_enrollments module#

Django management command for creating EnterpriseCourseEnrollment records.

class enterprise.management.commands.create_enterprise_course_enrollments.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Creates EnterpriseCourseEnrollment records (if they do not already exist) for CourseEnrollment records that are associated with an enterprise user and a course run that exists in the enterprise’s catalog.

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

help = 'Create EnterpriseCourseEnrollment records for CourseEnrollment records associated with an enterprise.'#

enterprise.management.commands.create_missing_dsc_records module#

Django management command for creating DataSharingConsent records.

class enterprise.management.commands.create_missing_dsc_records.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Django management command for creating DataSharingConsent records

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

enterprise.management.commands.email_drip_for_missing_dsc_records module#

Django management command for sending an email to learners with missing DataSharingConsent records.

class enterprise.management.commands.email_drip_for_missing_dsc_records.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Django management command for sending an email to learners with missing DataSharingConsent records

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

emit_event(ec_user, course_id, enterprise_customer, greeting_name)#

Emit the Segment event which will be used by Braze to send the email

get_enterprise_course_enrollments(options)#

Get EnterpriseCourseEnrollment records according to the options and with dsc enabled

handle(*args, **options)#

Management command for sending an email to learners with a missing DSC. Designed to run daily.

Example usage:

$ ./manage.py email_drip_for_missing_dsc_records $ ./manage.py email_drip_for_missing_dsc_records –no-commit $ ./manage.py email_drip_for_missing_dsc_records –enrollment-before 2021-05-06 –no-commit $ ./manage.py email_drip_for_missing_dsc_records –enrollment-before 2021-05-06

enterprise.management.commands.ensure_singular_active_enterprise_customer_user module#

Django management command to ensure there is at most a single EnterpriseCustomerUser with active=True for each enterprise user.

class enterprise.management.commands.ensure_singular_active_enterprise_customer_user.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Django management command to ensure there is at most a single EnterpriseCustomerUser with active=True for each enterprise user.

Example usage: ./manage.py lms ensure_singular_active_enterprise_customer_user

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

enterprise.management.commands.fix_dsc_records module#

Django management command to Fix DSC records having spaces in there course Id.

class enterprise.management.commands.fix_dsc_records.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Django management command to Fix DSC records having spaces in there course Id.

This Command fixes the DSC records what were saved due to bug in our system and DSC records were saved with spaces.

Example usage: ./manage.py lms fix_dsc_records ./manage.py lms fix_dsc_records –no-commit

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

enterprise.management.commands.manufacture_data module#

Management command for making things with test factories

class enterprise.management.commands.manufacture_data.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Management command for generating Django records from factories with custom attributes

Example usage:

$ ./manage.py manufacture_data –model enterprise.models.enterprise_customer –name “Test Enterprise” –slug “test-enterprise”

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

Entry point for management command execution.

run_from_argv(argv)#

Re-implemented from django/django in order to support individual field customization. We will need to keep this method up to date with our current version of Django BaseCommand.

Uses parse_known_args instead of parse_args to not throw an error when encountering unknown arguments

https://docs.python.org/3.8/library/argparse.html#argparse.ArgumentParser.parse_known_args

class enterprise.management.commands.manufacture_data.Node(data)#

Bases: object

Non-binary tree node class for building out a dependency tree of objects to create with customizations.

add_child(obj)#

Add a child to the current node

build_records()#

Recursively build out the tree of objects by first dealing with children nodes before getting to the parent.

find_value(value)#

Find a value in the tree

set_single_customization(field, value)#

Set a single customization value to the current node, overrides existing values under the same key.

enterprise.management.commands.manufacture_data.all_subclasses(cls)#

Recursively get all subclasses of a class https://stackoverflow.com/a/3862957

enterprise.management.commands.manufacture_data.build_tree_from_field_list(list_of_fields, provided_factory, base_node, customization_value)#

Builds a non-binary tree of nodes based on a list of children nodes, using a base node and it’s associated data factory as the parent node the user provided value as a reference to a potential, existing record.

  • list_of_fields (list of strings): the linked list of associated objects to create. Example-

    [‘enterprise_customer_user’, ‘enterprise_customer’, ‘site’]

  • provided_factory (factory.django.DjangoModelFactory): The data factory of the base_node.

  • base_node (Node): The parent node of the desired tree to build.

  • customization_value (string): The value to be assigned to the object associated with the last value in the

    list_of_fields param. Can either be a FK if the last value is a subfactory, or alternatively a custom value to be assigned to the field. Example- list_of_fields = [‘enterprise_customer_user’, ‘enterprise_customer’, ‘site’], customization_value = 9 or list_of_fields = [‘enterprise_customer_user’, ‘enterprise_customer’, ‘name’], customization_value = “FRED”

enterprise.management.commands.manufacture_data.convert_to_pascal(string)#

helper method to convert strings to Pascal case.

enterprise.management.commands.manufacture_data.pairwise(iterable)#

Convert a list into a list of tuples of adjacent elements. s -> [ (s0, s1), (s2, s3), (s4, s5), … ]

enterprise.management.commands.migrate_enterprise_catalogs module#

Django management command for migrating EnterpriseCustomerCatalog data to new service.

class enterprise.management.commands.migrate_enterprise_catalogs.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Migrate EnterpriseCustomerCatalog data to new Enterprise Catalog service.

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

help = 'Migrate EnterpriseCustomerCatalog data to new Enterprise Catalog service.'#

enterprise.management.commands.monthly_impact_report module#

Django management command to send monthly impact report to enterprise admins.

class enterprise.management.commands.monthly_impact_report.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Django management command to send monthly impact report to enterprise admins.

Example usage: ./manage.py lms monthly_impact_report ./manage.py lms monthly_impact_report –no-commit

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

emit_event(**kwargs)#

Emit the Segment event which will be used by Braze to send the email

get_query_results_from_snowflake()#

Get query results from Snowflake and yield each row.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

enterprise.management.commands.nudge_dormant_enrolled_enterprise_learners module#

Django management command to send nudge email to dormant enrolled enterprise learners.

class enterprise.management.commands.nudge_dormant_enrolled_enterprise_learners.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Django management command to send nudge email to dormant enrolled enterprise learners.

Example usage: ./manage.py lms nudge_dormant_enrolled_enterprise_learners ./manage.py lms nudge_dormant_enrolled_enterprise_learners –no-commit

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

emit_event(**kwargs)#

Emit the Segment event which will be used by Braze to send the email

get_query_results_from_snowflake()#

Get query results from Snowflake and yield each row.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

enterprise.management.commands.reencrypt_enterprise_customer_reporting_config_passwords module#

Django management command to reencrypt passwords in enterprise custom reporting configs.

class enterprise.management.commands.reencrypt_enterprise_customer_reporting_config_passwords.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Django management command to reencrypt passwords in enterprise custom reporting configs It’s useful when following encryption keys are rotated - FERNET_KEYS - LMS_FERNET_KEY

Example usage: ./manage.py lms reencrypt_enterprise_customer_reporting_config_passwords

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

enterprise.management.commands.remove_expired_pending_group_memberships module#

Management command for ensuring any pending group membership, ie memberships associated with a pending enterprise user, are removed after 90 days.

class enterprise.management.commands.remove_expired_pending_group_memberships.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Management command for ensuring any pending group membership, ie memberships associated with a pending enterprise user, are removed after 90 days. Optionally supply a --enterprise_customer arg to only run this command on a singular customer.

Example usage:

$ ./manage.py remove_expired_pending_group_memberships

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

help = 'Removes pending group memberships if they are older than 90 days.'#

enterprise.management.commands.revert_enrollment_objects module#

Management command for reverting revoked enrollment related objects to a particular time.

class enterprise.management.commands.revert_enrollment_objects.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Management command for reverting revoked enrollment related objects to a particular time.

Example usage:

$ ./manage.py revert_enrollment_objects –year 2021 –month 11 –day 17 –enterprise-customer-name test-co

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

Entry point for management command execution.

help = 'Reverts revoked enrollment related objects to a particular time.'#
revert_enrollment_objects(options)#

Revert all EnterpriseCourseEnrollment, LicensedEnterpriseCourseEnrollment, and “student” CourseEnrollment objects to the date provided, using the history table IF is_revoked = True on LicensedEnterpriseCourseEnrollment

enterprise.management.commands.save_enterprise_customer_users module#

Django management command for saving EnterpriseCustomerUser models.

class enterprise.management.commands.save_enterprise_customer_users.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Calls save() on EnterpriseCustomerUser models.

This is useful for triggering save-related signals causing the associated signal receiver functions to fire.

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

help = 'Save existing EnterpriseCustomerUser models.'#

enterprise.management.commands.seed_enterprise_devstack_data module#

Management command for assigning enterprise roles to existing enterprise users.

class enterprise.management.commands.seed_enterprise_devstack_data.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Management command for populating Devstack with initial data for enterprise.

Example usage:

$ ./manage.py lms seed_enterprise_devstack_data

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

Entry point for management command execution.

help = '\n    Seeds an enterprise customer, users of various roles and permissions initial\n    data in devstack for related Enterprise models.\n    '#

enterprise.management.commands.update_config_last_errored_at module#

Backfill missing audit record foreign keys.

class enterprise.management.commands.update_config_last_errored_at.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: IntegratedChannelCommandMixin, BaseCommand

Management command which backfills missing audit record foreign keys.

handle(*args, **options)#

Set error state for configurations.

help = '\n    Set error state for configurations.\n    '#
update_config_last_errored_at()#

For each audit record kind (learner and content), find all the records in batch, and lookup if they’ve had recent sync errors in the last day. If not, clear out the last_content_sync_errored_at value associated with the configuration.

enterprise.management.commands.update_role_assignments_with_customers module#

Management command for updating enterprise user role assignments with appropriate enterprise_customer and applies_to_all_contexts values.

class enterprise.management.commands.update_role_assignments_with_customers.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Management command for creating enterprise role assignments with a foreign key to an EnterpriseCustomer, or an explicit boolean flag indicating that the assignment grants the role to the user for every EnterpriseCustomer.

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

Entry point for managment command execution.

help = '\n    Applies explicit enterprise customer context for enterprise admin, learner, and catalog system role assignments.\n    It also sets `applies_to_all_contexts` to true for assignments of the `enterprise_openedx_operator` role.\n    Example usage:\n      # Do a dry run for admin assignments of some customer\n      ./manage.py lms update_role_assignments_with_customers --role=enterprise_admin --dry-run --enterprise-customer-uuid=00000000-1111-2222-3333-444444444444\n      # Do a real run for all operators\n      ./manage.py lms update_role_assignments_with_customers --role=enterprise_openedx_operator\n      # Process everything for everyone\n      ./manage.py lms update_role_assignments_with_customers\n    '#

Module contents#