<commit_before>from django.conf import settings
from django.core.mail import send_mail
from django.contrib.sites.models import Site
from django.db.models.signals import class_prepared, post_save
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _

from .models import Project, Update

def render_mail(template, context):
    subject = render_to_string('zipfelchappe/emails/%s_subject.txt' % template,
        context).strip()
    message = render_to_string('zipfelchappe/emails/%s_message.txt' % template,
        context)

    return subject, message


def send_update_mail(sender, instance, **kwargs):
    # XXX why not instance.project?
    update = instance
    project = Project.objects.get(pk=update.project.pk)

    if update.status == 'draft' or update.mails_sent:
        return

    for pledge in project.authorized_pledges.all():
        backer = pledge.backer

        ctx = {
            'update': update,
            'project': project,
            'backer': backer,
            'site': Site.objects.get_current()
        }

        subject, message = render_mail('new_update', ctx)

        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
            [backer.email], fail_silently=True)

    update.mails_sent = True
    update.save()

post_save.connect(send_update_mail, sender=Update)

def send_successful_message(project, pledge):
    backer = pledge.backer

    ctx = {
        'project': project,
        'pledge': pledge,
        'backer': backer,<commit_msg>disable update email<commit_after>from django.conf import settings
from django.core.mail import send_mail
from django.contrib.sites.models import Site
from django.db.models.signals import class_prepared, post_save
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _

from .models import Project, Update

def render_mail(template, context):
    subject = render_to_string('zipfelchappe/emails/%s_subject.txt' % template,
        context).strip()
    message = render_to_string('zipfelchappe/emails/%s_message.txt' % template,
        context)

    return subject, message


def send_update_mail(sender, instance, **kwargs):
    update = instance
    project = instance.project

    if update.status == 'draft' or update.mails_sent:
        return

    for pledge in project.authorized_pledges.all():
        backer = pledge.backer

        ctx = {
            'update': update,
            'project': project,
            'backer': backer,
            'site': Site.objects.get_current()
        }

        subject, message = render_mail('new_update', ctx)

        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
            [backer.email], fail_silently=True)

    update.mails_sent = True
    update.save()

#post_save.connect(send_update_mail, sender=Update)

def send_successful_message(project, pledge):
    backer = pledge.backer

    ctx = {
        'project': project,
        'pledge': pledge,
        'backer': backer,
{'fraction_non_alphanumeric': 0.09746460322686862, 'fraction_numerical': 0.0, 'mean_word_length': 3.1616438356164385, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5594124', 'n_tokens_mistral': 905, 'n_tokens_neox': 870, 'n_words': 205}