lms.djangoapps.mailing.management.commands package#

Submodules#

lms.djangoapps.mailing.management.commands.mailchimp_id module#

mailchimp_id: Returns whether or not a given mailchimp key represents a valid list.

class lms.djangoapps.mailing.management.commands.mailchimp_id.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Given a mailchimp key, validates that a list with that key exists in mailchimp.

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

Validates that the id passed in exists in mailchimp.

help = 'Get the list id from a web_id'#

lms.djangoapps.mailing.management.commands.mailchimp_sync_announcements module#

Synchronizes the announcement list with all active students.

class lms.djangoapps.mailing.management.commands.mailchimp_sync_announcements.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Synchronizes the announcement list with all active students.

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 = 'Synchronizes the announcement list with all active students.'#
lms.djangoapps.mailing.management.commands.mailchimp_sync_announcements.get_data(users, exclude=None)#

users: set of Django users exclude [optional]: set of Django users to exclude

returns: {‘EMAIL’: u.email} for all users in users less those in exclude

lms.djangoapps.mailing.management.commands.mailchimp_sync_announcements.get_enrolled()#

Filter out all users who signed up via a Microsite, which UserSignupSource tracks

lms.djangoapps.mailing.management.commands.mailchimp_sync_course module#

Synchronizes a mailchimp list with the students of a course.

class lms.djangoapps.mailing.management.commands.mailchimp_sync_course.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Synchronizes a mailchimp list with the students of a course.

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)#

Synchronizes a mailchimp list with the students of a course.

help = 'Synchronizes a mailchimp list with the students of a course.'#
lms.djangoapps.mailing.management.commands.mailchimp_sync_course.chunk(elist, size)#

Generator. Yields a list of size size of the given list elist, or a shorter list if at the end of the input.

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.connect_mailchimp(api_key)#

Initializes connection to the mailchimp api

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.get_cleaned(mailchimp, list_id)#

Returns a set of email addresses that have been cleaned from list_id

These email addresses may be invalid or have caused bounces, so you don’t want to re-add them back to the list.

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.get_enrolled_students(course_id)#

Given a course_id, returns a QuerySet of all the active students in the course.

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.get_members(mailchimp, list_id, status)#

Given a mailchimp list id and a user status to filter on, returns all members of the mailchimp list with that status.

Returns a set of email addresses.

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.get_student_data(students, exclude=None)#

Given a QuerySet of Django users, extracts id, username, and is_anonymous data. Excludes any users provided in the optional exclude set.

Returns a list of dictionaries for each user, where the dictionary has keys ‘EMAIL’, ‘FULLNAME’, and ‘EDX_ID’.

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.get_subscribed(mailchimp, list_id)#

Returns a set of email addresses subscribed to list_id

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.get_unsubscribed(mailchimp, list_id)#

Returns a set of email addresses that have unsubscribed from list_id

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.make_segments(mailchimp, list_id, count, emails)#

Segments the list of email addresses emails into count segments, if count is nonzero.

For unknown historical reasons, lost to the winds of time, this is done with a random order to the email addresses.

First, existing ‘random_’ mailchimp segments are deleted.

Then, the list of emails (the whole, large list) is shuffled.

Finally, the shuffled emails are chunked into count segments and re-uploaded to mailchimp as ‘random_’-prefixed segments.

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.name_to_tag(name)#

Returns sanitized str name: no more than 10 characters, with spaces replaced with _

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.subscribe_with_data(mailchimp, list_id, user_data)#

Given user_data in the form of a list of dictionaries for each user, where the dictionary has keys ‘EMAIL’, ‘FULLNAME’, and ‘EDX_ID’, batch subscribe the users to the given list_id via a Mailchimp api method.

Returns None

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.unsubscribe(mailchimp, list_id, emails)#

Batch unsubscribe the given email addresses from the list represented by list_id

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.update_merge_tags(mailchimp, list_id, tag_names)#

This function is rather inscrutable. Given tag_names, which in this code seems to be a list of [‘FULLNAME’, ‘EMAIL’, ‘EDX_ID’], we grab tags from the mailchimp list, then we verify tag_names has ‘FULLNAME’ and ‘EMAIL’ present, we get more data from mailchimp, then sync the variables up to mailchimp using listMergeVarAdd.

The purpose of this function is unclear.

lms.djangoapps.mailing.management.commands.mailchimp_sync_course.verify_list(mailchimp, list_id, course_id)#

Verifies that the given list_id corresponds to the course_id Returns boolean: whether or not course_id matches list_id

Module contents#