<commit_before>from django.shortcuts import render_to_response
from django.template.context import RequestContext

from models import *
import datetime


def auditAll(request, template="auditcare/index.html"):
    auditEvents = couchmodels.AuditEvent.view("auditcare/by_date").all()
    context = RequestContext(request)

    realEvents = [{"user":a["key"][0], "type":a["key"][1], "path":a["key"][2], "date":
                    datetime.datetime(year=int(a["key"][3]),
                                      month=int(a["key"][4]),
                                      day=int(a["key"][5]),
                                      hour=a["key"][6],
                                      minute=a["key"][7],
                                      second=a["key"][8])} for a in auditEvents]
    context['auditEvents'] = realEvents
    return render_to_response(template, context)<commit_msg>audit_login view that checks failed passwords<commit_after>from django.shortcuts import render_to_response
from django.template.context import RequestContext
from django.contrib.auth import authenticate
from django.contrib.auth.views import login as django_login
from signals import *
from models import *
import datetime


def auditAll(request, template="auditcare/index.html"):
    auditEvents = couchmodels.AuditEvent.view("auditcare/by_date").all()
    context = RequestContext(request)

    realEvents = [{"user":a["key"][0], "type":a["key"][1], "path":a["key"][2], "date":
                    datetime.datetime(year=int(a["key"][3]),
                                      month=int(a["key"][4]),
                                      day=int(a["key"][5]),
                                      hour=a["key"][6],
                                      minute=a["key"][7],
                                      second=a["key"][8])} for a in auditEvents]
    context['auditEvents'] = realEvents
    return render_to_response(template, context)

def audit_login(request, template_name, *args, **kwargs):
    username=request.POST.get('username')
    u = authenticate(username=username,password=request.POST.get('password'))
    if u is None or not u.is_active:
        user_login_failed.send(sender=None,request=request,username=username) # This is new
    return django_login(request, *args, **kwargs)

#django.contrib.auth.views.login = audit_login
{'fraction_non_alphanumeric': 0.1377245508982036, 'fraction_numerical': 0.007698887938408896, 'mean_word_length': 2.522590361445783, 'pattern_counts': {'":': 8, '<': 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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '871980', 'n_tokens_mistral': 662, 'n_tokens_neox': 643, 'n_words': 122}