<commit_before>from datetime import timedelta

from django.db import models
from django.core.mail import send_mail
from django.conf import settings
from django.utils import timezone

from slugify import slugify

from django.core.urlresolvers import reverse

from dashboard.models import SiteOptions
from comics.email import COMIC_EMAIL, COMIC_EMAIL_HTML
import random_name

from .email import VERIFICATION_EMAIL, VERIFICATION_EMAIL_HTML

class SpamSpamSpamSpam(Exception):
    """
    Thrown when you try to email the EmailSubscriber more than once a day.
    """
    pass

class EmailSubscriber(models.Model):
    """
    One e-mail, subscribed to your comic.
    """
    email = models.CharField(max_length=100, null=False, blank=False, unique=True)
    verification_code = models.CharField(max_length=200, null=False, blank=False)
    verified = models.BooleanField(default=False)
    created = models.DateTimeField()
    last_email_sent = models.DateTimeField()

    def save(self):
        if not self.id:
            self.created = timezone.now()
            self.last_email_sent = timezone.now()
        if not self.verification_code:
            self.verification_code = slugify(random_name.special_thing())
        super().save()

    def send_verification_email(self):
        site_options = SiteOptions.get()

        site_url = settings.SITE_URL
        verification_relative_url = reverse('publish.views.verify',
                                            kwargs={'email':self.email,
                                                    'verification_code':self.verification_code})
        verification_absolute_url = "{}{}".format(site_url, verification_relative_url)

        subject = "Welcome to {}!".format(site_options.title)
        message = VERIFICATION_EMAIL.format(verification_absolute_url)
        messsage_html = VERIFICATION_EMAIL_HTML.format(verification_absolute_url)<commit_msg>fix to subscribing<commit_after>from datetime import timedelta

from django.db import models
from django.core.mail import send_mail
from django.conf import settings
from django.utils import timezone

from slugify import slugify

from django.core.urlresolvers import reverse

from dashboard.models import SiteOptions
from comics.email import COMIC_EMAIL, COMIC_EMAIL_HTML
import random_name

from .email import VERIFICATION_EMAIL, VERIFICATION_EMAIL_HTML

class SpamSpamSpamSpam(Exception):
    """
    Thrown when you try to email the EmailSubscriber more than once a day.
    """
    pass

class EmailSubscriber(models.Model):
    """
    One e-mail, subscribed to your comic.
    """
    email = models.CharField(max_length=100, null=False, blank=False, unique=True)
    verification_code = models.CharField(max_length=200, null=False, blank=False)
    verified = models.BooleanField(default=False)
    created = models.DateTimeField()
    last_email_sent = models.DateTimeField()

    def save(self):
        if not self.id:
            self.created = timezone.now()
            self.last_email_sent = timezone.now()
        if not self.verification_code:
            self.verification_code = slugify(random_name.special_thing())
        super().save()

    def send_verification_email(self):
        site_options = SiteOptions.get()

        site_url = settings.SITE_URL
        verification_relative_url = reverse('publish.views.verify',
                                            kwargs={'email':self.email,
                                                    'verification_code':self.verification_code})
        verification_absolute_url = "{}{}".format(site_url, verification_relative_url)

        subject = "Welcome to {}!".format(site_options.title)
        message = VERIFICATION_EMAIL.format(verification_absolute_url)
        message_html = VERIFICATION_EMAIL_HTML.format(verification_absolute_url)
{'fraction_non_alphanumeric': 0.08267922553636839, 'fraction_numerical': 0.0031397174254317113, 'mean_word_length': 3.1872946330777654, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7459997', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1054, 'n_words': 239}