<commit_before># -*- coding: utf-8 -*-
from django.contrib import messages
from django.core.mail.message import EmailMessage
from django.core.urlresolvers import reverse_lazy, reverse
from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import TemplateView
from django.views.generic.edit import FormView
from django.core.mail import send_mail

from boski.mixins import BreadcrumbsMixin

from module.static_page.models import Entry
from .models import Mail
from .forms import MailForm


class Index(BreadcrumbsMixin, FormView):
    template_name = 'about/index.html'
    breadcrumbs = ((_('About'), reverse_lazy('about:index')),)
    form_class = MailForm
    success_url = reverse_lazy('about:index')

    def get_context_data(self, **kwargs):
        context = super(Index, self).get_context_data(**kwargs)

        about_page, created = Entry.objects.get_or_create(slug='about')
        if created:
            about_page.title = 'About'
            about_page.save()

        context['about_page'] = about_page

        return context

    def form_invalid(self, form):
        messages.error(self.request, _('Please check contact form'))
        return super(Index, self).form_invalid(form)

    def form_valid(self, form):
        """
        Saving and sending email
        @param form:
        @return:
        """
        mail_entry = form.save(commit=False)
        mail_entry.ua = self.request.META['HTTP_USER_AGENT']
        mail_entry.ip = self.request.META['REMOTE_ADDR']
        mail_entry.save()

        # sending email
        try:
            email = EmailMessage(mail_entry.subject, mail_entry.content, '%s <%s>' % (mail_entry.author, mail_entry.email),
                ['<EMAIL>', '<EMAIL>'], ['<EMAIL>'],
                headers={'Reply-To': '%s <%s>' % (mail_entry.author, mail_entry.email)})
            email.send(fail_silently=False)
        except:<commit_msg>Fixed sending emails Emails are now send to emails in settings.ADMINS<commit_after># -*- coding: utf-8 -*-
from django.contrib import messages
from django.core.mail.message import EmailMessage
from django.core.urlresolvers import reverse_lazy, reverse
from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import TemplateView
from django.views.generic.edit import FormView
from django.core.mail import send_mail

from dc.settings import ADMINS

from boski.mixins import BreadcrumbsMixin

from module.static_page.models import Entry
from .models import Mail
from .forms import MailForm


class Index(BreadcrumbsMixin, FormView):
    template_name = 'about/index.html'
    breadcrumbs = ((_('About'), reverse_lazy('about:index')),)
    form_class = MailForm
    success_url = reverse_lazy('about:index')

    def get_context_data(self, **kwargs):
        context = super(Index, self).get_context_data(**kwargs)

        about_page, created = Entry.objects.get_or_create(slug='about')
        if created:
            about_page.title = 'About'
            about_page.save()

        context['about_page'] = about_page

        return context

    def form_invalid(self, form):
        messages.error(self.request, _('Please check contact form'))
        return super(Index, self).form_invalid(form)

    def form_valid(self, form):
        """
        Saving and sending email
        @param form:
        @return:
        """
        mail_entry = form.save(commit=False)
        mail_entry.ua = self.request.META['HTTP_USER_AGENT']
        mail_entry.ip = self.request.META['REMOTE_ADDR']
        mail_entry.save()

        # sending email
        try:
            email = EmailMessage(mail_entry.subject, mail_entry.content, '%s <%s>' % (mail_entry.author, mail_entry.email),
                [a[1] for a in ADMINS],
                headers={'Reply-To': '%s <%s>' % (mail_entry.author, mail_entry.email)})
            email.send(fail_silently=False)
        except:
{'fraction_non_alphanumeric': 0.11182027061526678, 'fraction_numerical': 0.0007658922644881287, 'mean_word_length': 3.0897703549060545, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '2059125', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1156, 'n_words': 269}