示例#1
0
def activation_task(custom_template_text, email_recipient_list,
                    subscription_uuid):
    """
    Sends license activation email(s) asynchronously, and creates pending enterprise users to link the email recipients
    to the subscription's enterprise.

    Arguments:
        custom_template_text (dict): Dictionary containing `greeting` and `closing` keys to be used for customizing
            the email template.
        email_recipient_list (list of str): List of recipients to send the emails to.
        subscription_uuid (str): UUID (string representation) of the subscription that the recipients are associated
            with or will be associated with.
    """
    subscription_plan = SubscriptionPlan.objects.get(uuid=subscription_uuid)
    pending_licenses = subscription_plan.licenses.filter(
        user_email__in=email_recipient_list).order_by('uuid')
    enterprise_api_client = EnterpriseApiClient()
    enterprise_slug = enterprise_api_client.get_enterprise_slug(
        subscription_plan.enterprise_customer_uuid)
    send_activation_emails(custom_template_text, pending_licenses,
                           enterprise_slug)
    License.set_date_fields_to_now(pending_licenses,
                                   ['last_remind_date', 'assigned_date'])

    for email_recipient in email_recipient_list:
        enterprise_api_client.create_pending_enterprise_user(
            subscription_plan.enterprise_customer_uuid,
            email_recipient,
        )
示例#2
0
def link_learners_to_enterprise_task(learner_emails, enterprise_customer_uuid):
    """
    Links learners to an enterprise asynchronously.

    Arguments:
        learner_emails (list): list containing the list of learner emails to link to the enterprise
        enterprise_customer_uuid (str): UUID (string representation) of the enterprise to link learns to
    """
    enterprise_api_client = EnterpriseApiClient()
    for learner_email in learner_emails:
        enterprise_api_client.create_pending_enterprise_user(
            enterprise_customer_uuid,
            learner_email,
        )