enterprise.management.commands package

Contents

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_ecu_table_user_foreign_key module#

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

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

Bases: BaseCommand

Management command to copy user_id values to the foreign key user_fk field in the enterprise_customer_user table.

Example usage:

$ ./manage.py backfill_ecu_table_user_foreign_key

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

backfill_ecu_table_user_foreign_key(options)#

Backfills user_fk from user_id in batches with timeout, retries, and progress reporting.

handle(*_args, **options)#

Entry point for management command execution.

help = '\n    Goes through the Enterprise Customer User table in batches\n    and copies the user_id to the user_fk foreign key.\n    '#
enterprise.management.commands.backfill_ecu_table_user_foreign_key.safe_bulk_update(entries, properties, max_retries, manager)#

Performs bulk_update with retry logic.

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_enterprise_customer_admins module#

Management command to create EnterpriseCustomerAdmin records for users with the enterprise_admin role.

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

Bases: BaseCommand

Create EnterpriseCustomerAdmin records for users with the enterprise_admin role.

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 = 'Creates EnterpriseCustomerAdmin records for users with the enterprise_admin role'#

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.11/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.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.send_pending_admin_reminders module#

Management command for sending reminder emails to pending enterprise customer admin users.

This command should be run on a scheduled basis (via cron) to send reminder emails to admins who have pending invites that are due for a reminder.

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

Bases: BaseCommand

Management command for sending reminder emails to pending enterprise customer admin users.

This command calls the enterprise task function directly (synchronously) to send reminders to admin invites that are due based on the configured delay and max reminder count.

Example usage:

$ ./manage.py lms send_pending_admin_reminders

This command is intended to be run periodically via cron/Jenkins on a production schedule (e.g., hourly or daily).

For testing in devstack, you can run it manually to trigger reminders.

handle(*args, **options)#

Execute the command to send pending admin reminders.

help = 'Sends reminder emails to pending enterprise admin invites that are due for reminders.'#

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_enterprise_social_auth_uids module#

Django management command to update the social auth records UID

exception enterprise.management.commands.update_enterprise_social_auth_uids.CSVUpdateError#

Bases: Exception

Custom exception for CSV update process.

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

Bases: BaseCommand

Update the enterprise related social auth records UID to the new one.

Example usage: ./manage.py lms update_enterprise_social_auth_uids csv_file_path ./manage.py lms update_enterprise_social_auth_uids csv_file_path –old-prefix=”slug:” –new-prefix=”slug:x|{}@xyz” ./manage.py lms update_enterprise_social_auth_uids csv_file_path –no-dry-run

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 = 'Records update from CSV with console logging'#
update_record(row, dry_run=True, old_prefix=None, new_prefix=None)#

Update a single record, applying optional prefixes to UIDs if provided.

Parameters:
  • row (dict) – CSV row data

  • dry_run (bool) – Whether to simulate or actually save changes

  • old_prefix (str) – Prefix to apply to the old UID

  • new_prefix (str) – Prefix to apply to the new UID

Returns:

Whether the update was successful

Return type:

bool

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    '#

enterprise.management.commands.validate_default_enrollment_intentions module#

Django management command to validate that DefaultEnterpriseEnrollmentIntention objects have enrollable content.

class enterprise.management.commands.validate_default_enrollment_intentions.Command(*args, **kwargs)#

Bases: BaseCommand

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

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.

handle_intention(intention)#

Check that the default enrollment intention’s content_key is contained in any of the customer’s catalogs.

Returns:

Results dict that indicates whether evaluation was skipped, and whether the intention was valid.

Return type:

dict

property latest_change_allowed#

Module contents#