<commit_before>#-*- coding: utf-8 -*-
from notifyme.delivery.base import BaseDeliveryBackend
from django.conf import settings
from django.template.loader import render_to_string
from django.core.mail import send_mail

class EmailBackend(BaseDeliveryBackend):
    identifier = 'email'
    from_email = settings.DEFAULT_FROM_EMAIL

    def get_email(self, user):
        return user.email

    def get_from_email(self, user=None):
        return self.from_email

    def deliver_to(self, user, context, notice, language):
        email = self.get_email(user)
        context.update({
            'email': email,
        })
        subject = render_to_string(
            (
                "notifyme/notices/%s/email/subject.txt" % notice.identifier,
                "notifyme/notices/generic/email/subject.txt",
            ),
            context_instance=context
        )
        body = render_to_string(
            (
                "notifyme/notices/%s/email/body.txt" % notice.identifier,
                "notifyme/notices/generic/email/body.txt",
            ),
            context_instance=context
        )
        body_html = render_to_string(
            (
                "notifyme/notices/%s/email/body.html" % notice.identifier,
                "notifyme/notices/generic/email/body.html",
            ),
            context_instance=context
        )
        # TODO: send html
        send_mail(subject, body, self.get_from_email(user), [email])
        
        <commit_msg>simplified from mail<commit_after>#-*- coding: utf-8 -*-
from notifyme.delivery.base import BaseDeliveryBackend
from django.conf import settings
from django.template.loader import render_to_string
from django.core.mail import send_mail

class EmailBackend(BaseDeliveryBackend):
    identifier = 'email'

    def get_email(self, user):
        return user.email

    def get_from_email(self, user=None):
        return settings.DEFAULT_FROM_EMAIL

    def deliver_to(self, user, context, notice, language):
        email = self.get_email(user)
        context.update({
            'email': email,
        })
        subject = render_to_string(
            (
                "notifyme/notices/%s/email/subject.txt" % notice.identifier,
                "notifyme/notices/generic/email/subject.txt",
            ),
            context_instance=context
        )
        body = render_to_string(
            (
                "notifyme/notices/%s/email/body.txt" % notice.identifier,
                "notifyme/notices/generic/email/body.txt",
            ),
            context_instance=context
        )
        body_html = render_to_string(
            (
                "notifyme/notices/%s/email/body.html" % notice.identifier,
                "notifyme/notices/generic/email/body.html",
            ),
            context_instance=context
        )
        # TODO: send html
        send_mail(subject, body, self.get_from_email(user), [email])
        
        
{'fraction_non_alphanumeric': 0.09972862957937585, 'fraction_numerical': 0.0006784260515603799, 'mean_word_length': 1.9401794616151546, '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': '2949105', 'n_tokens_mistral': 846, 'n_tokens_neox': 832, 'n_words': 142}