<commit_before>from django.core.mail import EmailMultiAlternatives, send_mail
from django.conf import settings
from django.template.loader import render_to_string


def send_new_site_email(user, site):
    context = {"user": user, "site": site}
    plain_message = render_to_string("emails/new_site_added.txt", context)
    html_message = render_to_string("emails/new_site_added.html", context)
    if settings.DEBUG:
        print(plain_message)
        return 0
    else:
        return send_mail("{} You've been added to a new website!".format(settings.EMAIL_SUBJECT_PREFIX),
                         plain_message, settings.EMAIL_FROM,
                         [user.email], html_message=html_message)


def send_approval_request_email(request):
    context = {"request": request}
    plain_message = render_to_string("emails/approval_request.txt", context)
    html_message = render_to_string("emails/approval_request.html", context)
    if settings.DEBUG:
        print(plain_message)
        return 0
    else:
        msg = EmailMultiAlternatives(subject="{} A website request ({}) needs your approval!".format(settings.EMAIL_SUBJECT_PREFIX, request.activity),
                                     body=plain_message,
                                     from_email=settings.EMAIL_FROM,
                                     to=[request.teacher.email],
                                     reply_to=[settings.EMAIL_FEEDBACK])
        msg.attach_alternative(html_message, "text/html")
        return msg.send()


def send_admin_request_email(request):
    context = {"request": request}
    plain_message = render_to_string("emails/admin_request.txt", context)
    html_message = render_to_string("emails/admin_request.html", context)
    if settings.DEBUG:
        print(plain_message)
        return 0
    else:
        msg = EmailMultiAlternatives(subject="{} A website request ({} - {}) requires processing!".format(settings.EMAIL_SUBJECT_PREFIX, request.activity, request.user.full_name),
                                     body=plain_message,
                                     from_email=settings.EMAIL_FROM,
                                     to=[settings.EMAIL_FEEDBACK],
                                     reply_to=[request.user.email, settings.EMAIL_FEEDBACK])
        msg.attach_alternative(html_message, "text/html")<commit_msg>add email variable to emails<commit_after>from django.core.mail import EmailMultiAlternatives, send_mail
from django.conf import settings
from django.template.loader import render_to_string


def send_new_site_email(user, site):
    context = {"user": user, "site": site, "contact_email": settings.EMAIL_CONTACT}
    plain_message = render_to_string("emails/new_site_added.txt", context)
    html_message = render_to_string("emails/new_site_added.html", context)
    if settings.DEBUG:
        print(plain_message)
        return 0
    else:
        return send_mail("{} You've been added to a new website!".format(settings.EMAIL_SUBJECT_PREFIX),
                         plain_message, settings.EMAIL_FROM,
                         [user.email], html_message=html_message)


def send_approval_request_email(request):
    context = {"request": request, "contact_email": settings.EMAIL_CONTACT}
    plain_message = render_to_string("emails/approval_request.txt", context)
    html_message = render_to_string("emails/approval_request.html", context)
    if settings.DEBUG:
        print(plain_message)
        return 0
    else:
        msg = EmailMultiAlternatives(subject="{} A website request ({}) needs your approval!".format(settings.EMAIL_SUBJECT_PREFIX, request.activity),
                                     body=plain_message,
                                     from_email=settings.EMAIL_FROM,
                                     to=[request.teacher.email],
                                     reply_to=[settings.EMAIL_FEEDBACK])
        msg.attach_alternative(html_message, "text/html")
        return msg.send()


def send_admin_request_email(request):
    context = {"request": request}
    plain_message = render_to_string("emails/admin_request.txt", context)
    html_message = render_to_string("emails/admin_request.html", context)
    if settings.DEBUG:
        print(plain_message)
        return 0
    else:
        msg = EmailMultiAlternatives(subject="{} A website request ({} - {}) requires processing!".format(settings.EMAIL_SUBJECT_PREFIX, request.activity, request.user.full_name),
                                     body=plain_message,
                                     from_email=settings.EMAIL_FROM,
                                     to=[settings.EMAIL_FEEDBACK],
                                     reply_to=[request.user.email, settings.EMAIL_FEEDBACK])
        msg.attach_alternative(html_message, "text/html")
{'fraction_non_alphanumeric': 0.09361348034116913, 'fraction_numerical': 0.001248179737882255, 'mean_word_length': 2.4967272727272727, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5732439', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1286, 'n_words': 233}