<commit_before>#modified version of django-axes axes/decorator.py
#for more information see: http://code.google.com/p/django-axes/
import csv
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.contenttypes.models import ContentType
from django.http import HttpResponse
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
from auditcare.utils import login_template
from auditcare.decorators.login import lockout_response
from auditcare.decorators.login import log_request
from auditcare.inspect import history_for_doc

from django.conf import settings
from django.shortcuts import render
from auditcare import models
from auditcare.models import AccessAudit

import logging


LOCKOUT_TEMPLATE = getattr(settings, 'AXES_LOCKOUT_TEMPLATE', None)
LOCKOUT_URL = getattr(settings, 'AXES_LOCKOUT_URL', None)
VERBOSE = getattr(settings, 'AXES_VERBOSE', True)


def export_all(request):
    auditEvents = AccessAudit.view("auditcare/by_date_access_events", descending=True, include_docs=True).all()
    response = HttpResponse()
    response['Content-Disposition'] = 'attachment; filename="AuditAll.csv"'
    writer = csv.writer(response)<commit_msg>Require superuser to access auditcare logs<commit_after>#modified version of django-axes axes/decorator.py
#for more information see: http://code.google.com/p/django-axes/
import csv
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.contenttypes.models import ContentType
from django.http import HttpResponse
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
from auditcare.utils import login_template
from auditcare.decorators.login import lockout_response
from auditcare.decorators.login import log_request
from auditcare.inspect import history_for_doc

from django.conf import settings
from django.shortcuts import render
from auditcare import models
from auditcare.models import AccessAudit

import logging


LOCKOUT_TEMPLATE = getattr(settings, 'AXES_LOCKOUT_TEMPLATE', None)
LOCKOUT_URL = getattr(settings, 'AXES_LOCKOUT_URL', None)
VERBOSE = getattr(settings, 'AXES_VERBOSE', True)


@login_required
@user_passes_test(lambda u: u.is_superuser)
def export_all(request):
    auditEvents = AccessAudit.view("auditcare/by_date_access_events", descending=True, include_docs=True).all()
    response = HttpResponse()
    response['Content-Disposition'] = 'attachment; filename="AuditAll.csv"'
    writer = csv.writer(response)
{'fraction_non_alphanumeric': 0.07928488146132918, 'fraction_numerical': 0.0, 'mean_word_length': 6.82370820668693, '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': '6946001', 'n_tokens_mistral': 762, 'n_tokens_neox': 742, 'n_words': 192}