<commit_before>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4


from django.template import RequestContext
from django.shortcuts import render_to_response
from django.views.decorators.http import require_GET
from django.contrib.auth.views import login as django_login
from django.contrib.auth.views import logout as django_logout


@require_GET
def dashboard(req):
    return render_to_response(
        "dashboard.html",
        context_instance=RequestContext(req))


def login(req, template_name="rapidsms/login.html"):
    return django_login(req, **{"template_name" : template_name})


def logout(req, template_name="rapidsms/loggedout.html"):
    return django_logout(req, **{"template_name" : template_name})<commit_msg>add code to do auditlog on logon or logout<commit_after>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4


from django.template import RequestContext
from django.shortcuts import render_to_response
from django.views.decorators.http import require_GET
from django.contrib.auth.views import login as django_login
from django.contrib.auth.views import logout as django_logout
from auditlog.utils import audit_log


@require_GET
def dashboard(req):
    return render_to_response(
        "dashboard.html",
        context_instance=RequestContext(req))


def login(req, template_name="rapidsms/login.html"):
    response = django_login(req, **{"template_name" : template_name})
    if req.user.is_authenticated():
        log_dict = {'request': req, 'logtype': 'system', 'action':'login',
                    'detail':'User logged in %s:%s' % (req.user.id, req.user.username) }
        audit_log(log_dict)
    return response


def logout(req, template_name="rapidsms/loggedout.html"):
    log_dict = {'request': req, 'logtype': 'system', 'action':'logout',
                    'detail':'User logged out %s:%s' % (req.user.id, req.user.username) }
    audit_log(log_dict)
    return django_logout(req, **{"template_name" : template_name})
{'fraction_non_alphanumeric': 0.11749745676500509, 'fraction_numerical': 0.003051881993896236, 'mean_word_length': 4.572237960339943, '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': '6097329', 'n_tokens_mistral': 625, 'n_tokens_neox': 613, 'n_words': 147}