<commit_before>from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.management.base import BaseCommand
from django.core.urlresolvers import reverse

from post_office import mail


class Command(BaseCommand):
    help = "Notify users to update."

    def handle(self, *args, **options):
        domain = Site.objects.get_current().domain
        full_url = "https://{}{}".format(domain,
                                         reverse('edit_common_profile'))
        for user in User.objects.filter(common_profile__is_student=True,
                                        is_active=True):
            mail.send([user.email],
                       template="update_common_profile",
                       context={'user': user, 'full_url': full_url})
            self.stdout.write(u'Emailed {}.'.format(user.email))<commit_msg>Handle missing and invalid email addresses.<commit_after>from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
from django.core.management.base import BaseCommand
from django.core.urlresolvers import reverse


from post_office import mail


class Command(BaseCommand):
    help = "Notify users to update."

    def handle(self, *args, **options):
        domain = Site.objects.get_current().domain
        full_url = "https://{}{}".format(domain,
                                         reverse('edit_common_profile'))
        for user in User.objects.filter(common_profile__is_student=True,
                                        is_active=True).exclude(email=""):
            try:
                mail.send([user.email],
                          template="update_common_profile",
                          context={'user': user, 'full_url': full_url})
                self.stdout.write(u'Emailed {}.'.format(user.email))
            except ValidationError:
                self.stdout.write(u'Error with {}'.format(user.email))
            
{'fraction_non_alphanumeric': 0.1059174540029836, 'fraction_numerical': 0.0, 'mean_word_length': 2.234726688102894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7588291', 'n_tokens_mistral': 505, 'n_tokens_neox': 489, 'n_words': 112}