コード例 #1
0
ファイル: emails.py プロジェクト: xbryanc/commcare-hq
def send_subscription_change_alert(domain, new_subscription, old_subscription,
                                   internal_change):

    billing_account = (new_subscription.account if new_subscription else
                       old_subscription.account if old_subscription else None)
    # this can be None, though usually this will be initiated
    # by an http request
    request = get_request()
    email_context = {
        'domain':
        domain,
        'domain_url':
        get_default_domain_url(domain),
        'old_plan':
        old_subscription.plan_version if old_subscription else None,
        'new_plan':
        new_subscription.plan_version if new_subscription else None,
        'old_subscription':
        old_subscription,
        'new_subscription':
        new_subscription,
        'billing_account':
        billing_account,
        'username':
        request.couch_user.username
        if getattr(request, 'couch_user', None) else None,
        'referer':
        request.META.get('HTTP_REFERER') if request else None,
    }
    email_subject = "{env}Subscription Change Alert: {domain} from {old_plan} to {new_plan}".format(
        env=("[{}] ".format(settings.SERVER_ENVIRONMENT.upper())
             if settings.SERVER_ENVIRONMENT == "staging" else ""),
        domain=email_context['domain'],
        old_plan=email_context['old_plan'],
        new_plan=email_context['new_plan'],
    )

    sub_change_email_address = (settings.INTERNAL_SUBSCRIPTION_CHANGE_EMAIL
                                if internal_change else
                                settings.SUBSCRIPTION_CHANGE_EMAIL)

    send_html_email_async.delay(
        email_subject,
        sub_change_email_address,
        render_to_string('accounting/subscription_change_email.html',
                         email_context),
        text_content=render_to_string(
            'accounting/subscription_change_email.txt', email_context),
    )
コード例 #2
0
ファイル: emails.py プロジェクト: dimagi/commcare-hq
def send_subscription_change_alert(domain, new_subscription, old_subscription, internal_change):

    billing_account = (
        new_subscription.account if new_subscription else
        old_subscription.account if old_subscription else None
    )
    # this can be None, though usually this will be initiated
    # by an http request
    request = get_request()
    email_context = {
        'domain': domain,
        'domain_url': get_default_domain_url(domain),
        'old_plan': old_subscription.plan_version if old_subscription else None,
        'new_plan': new_subscription.plan_version if new_subscription else None,
        'old_subscription': old_subscription,
        'new_subscription': new_subscription,
        'billing_account': billing_account,
        'username': request.couch_user.username if getattr(request, 'couch_user', None) else None,
        'referer': request.META.get('HTTP_REFERER') if request else None,
    }
    email_subject = "{env}Subscription Change Alert: {domain} from {old_plan} to {new_plan}".format(
        env=("[{}] ".format(settings.SERVER_ENVIRONMENT.upper())
             if settings.SERVER_ENVIRONMENT == "staging" else ""),
        domain=email_context['domain'],
        old_plan=email_context['old_plan'],
        new_plan=email_context['new_plan'],
    )

    sub_change_email_address = (settings.INTERNAL_SUBSCRIPTION_CHANGE_EMAIL
                                if internal_change else settings.SUBSCRIPTION_CHANGE_EMAIL)

    send_html_email_async.delay(
        email_subject,
        sub_change_email_address,
        render_to_string('accounting/email/subscription_change.html', email_context),
        text_content=render_to_string('accounting/email/subscription_change.txt', email_context),
    )
コード例 #3
0
 def domain_properties(self, domain_obj):
     return [
         domain_obj.name,
         domain_obj.hr_name,
         get_default_domain_url(domain_obj.name),
     ]
コード例 #4
0
ファイル: enterprise.py プロジェクト: kkrampa/commcare-hq
 def domain_properties(self, domain_obj):
     return [
         domain_obj.name,
         domain_obj.hr_name,
         get_default_domain_url(domain_obj.name),
     ]