<commit_before>import json

from django.core.mail import mail_managers
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.core.urlresolvers import reverse

from core.forms import EntryForm


def home(request):
    return render(request, 'ui/home.html', {})


def adder(request):
    if request.method == 'POST':
        form = EntryForm(request.POST)
        if form.is_valid():
            text = _make_email_body(form.cleaned_data, request.META)
            mail_managers('TG', text)
            return HttpResponseRedirect(reverse('ui:takk'))
    else:
        form = EntryForm(initial={
            'want_issue': True,
            'want_tg': True,
            'num_issues': 1,
        })
    return render(request, 'ui/adder.html',
                  {
                      'form': form,
                  })


def _make_email_body(data, meta):
    text = ""
    for k in sorted(data.keys()):
        text += "{k}\n{v}\n\n".format(k=k.upper(), v=data[k])
    json_data = data.copy()
    for k in ['REMOTE_ADDR', 'HTTP_USER_AGENT', 'HTTP_REFERER']:
        json_data[k] = meta.get(k, None)
    text += "\njson: %s\n" % json.dumps(json_data)
    return text


def takk(request):
    return render(request, 'ui/takk.html', {})<commit_msg>Somewhat better subject on the emails<commit_after>import json

from django.core.mail import mail_managers
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.core.urlresolvers import reverse

from core.forms import EntryForm


def home(request):
    return render(request, 'ui/home.html', {})


def adder(request):
    if request.method == 'POST':
        form = EntryForm(request.POST)
        if form.is_valid():
            text = _make_email_body(form.cleaned_data, request.META)
            mail_managers(form.cleaned_data.get('first_name', '(utan namn)'),
                          text)
            return HttpResponseRedirect(reverse('ui:takk'))
    else:
        form = EntryForm(initial={
            'want_issue': True,
            'want_tg': True,
            'num_issues': 1,
        })
    return render(request, 'ui/adder.html',
                  {
                      'form': form,
                  })


def _make_email_body(data, meta):
    text = ""
    for k in sorted(data.keys()):
        text += "{k}\n{v}\n\n".format(k=k.upper(), v=data[k])
    json_data = data.copy()
    for k in ['REMOTE_ADDR', 'HTTP_USER_AGENT', 'HTTP_REFERER']:
        json_data[k] = meta.get(k, None)
    text += "\njson: %s\n" % json.dumps(json_data)
    return text


def takk(request):
    return render(request, 'ui/takk.html', {})
{'fraction_non_alphanumeric': 0.13355906696764486, 'fraction_numerical': 0.0007524454477050414, 'mean_word_length': 2.4622395833333335, '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': '863604', 'n_tokens_mistral': 866, 'n_tokens_neox': 840, 'n_words': 187}