def send_reminder_email_task(custom_template_text, email_recipient_list, subscription_uuid): """ Sends license activation reminder email(s) asynchronously. 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) enterprise_name = enterprise_api_client.get_enterprise_name( subscription_plan.enterprise_customer_uuid) try: send_activation_emails(custom_template_text, pending_licenses, enterprise_slug, enterprise_name, is_reminder=True) except Exception: # pylint: disable=broad-except msg = 'License manager reminder email sending received an exception for enterprise: {}.'.format( enterprise_name) logger.error(msg, exc_info=True) # Return without updating the last_remind_date for licenses return License.set_date_fields_to_now(pending_licenses, ['last_remind_date'])
def send_revocation_cap_notification_email_task(subscription_uuid): """ Sends revocation cap email notification to ECS asynchronously. Arguments: subscription_uuid (str): UUID (string representation) of the subscription that has reached its recovation cap. """ subscription_plan = SubscriptionPlan.objects.get(uuid=subscription_uuid) enterprise_api_client = EnterpriseApiClient() enterprise_name = enterprise_api_client.get_enterprise_name( subscription_plan.enterprise_customer_uuid) try: send_revocation_cap_notification_email( subscription_plan, enterprise_name, ) except Exception: # pylint: disable=broad-except logger.error( 'Revocation cap notification email sending received an exception.', exc_info=True)