<commit_before>import os

from django.shortcuts import render
from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response

from django.http import StreamingHttpResponse, HttpResponseNotFound
from django.contrib.auth.decorators import permission_required
from django.core.servers.basehttp import FileWrapper
from django.core.urlresolvers import reverse, reverse_lazy
from django.template import RequestContext

from django.contrib.auth.decorators import login_required

from excerptexport.models import ExtractionOrder
from excerptexport.models import Excerpt
from excerptexport.models import OutputFile
from excerptexport.models import BoundingGeometry
from excerptexport.models.extraction_order import ExtractionOrderState
from excerptexport import settings
from excerptexport.services.data_conversion_service import trigger_data_conversion


def has_excerptexport_all_permissions():
    excerpt_export_permissions = [
        'excerptexport.add_boundinggeometry',
        'excerptexport.change_boundinggeometry',
        'excerptexport.add_excerpt',
        'excerptexport.change_excerpt',
        'excerptexport.add_extractionorder',
        'excerptexport.change_extractionorder',
    ]
    # This is a simple hack, instead of displaying a login page, it shows a permission denied page if the user is
    # logged in
    login_url = reverse_lazy('excerptexport:access_denied')
    return permission_required(excerpt_export_permissions, login_url=login_url, raise_exception=False)


def access_denied(request):
    return render_to_response('excerptexport/templates/access_denied.html', context=RequestContext(request))


def index(request):
    return render_to_response('excerptexport/templates/index.html', context=RequestContext(request))

<commit_msg>Refactor views.py<commit_after>import os

from django.shortcuts import render, get_object_or_404, render_to_response

from django.http import StreamingHttpResponse, HttpResponseNotFound
from django.contrib.auth.decorators import permission_required
from django.core.servers.basehttp import FileWrapper
from django.core.urlresolvers import reverse, reverse_lazy
from django.template import RequestContext

from django.contrib.auth.decorators import login_required

from excerptexport.models import ExtractionOrder, Excerpt, OutputFile, BoundingGeometry
from excerptexport.models.extraction_order import ExtractionOrderState
from excerptexport import settings
from excerptexport.services.data_conversion_service import trigger_data_conversion


def has_excerptexport_all_permissions():
    excerpt_export_permissions = [
        'excerptexport.add_boundinggeometry',
        'excerptexport.change_boundinggeometry',
        'excerptexport.add_excerpt',
        'excerptexport.change_excerpt',
        'excerptexport.add_extractionorder',
        'excerptexport.change_extractionorder',
    ]
    # This is a simple hack, instead of displaying a login page, it shows a permission denied page if the user is
    # logged in
    login_url = reverse_lazy('excerptexport:access_denied')
    return permission_required(excerpt_export_permissions, login_url=login_url, raise_exception=False)


def access_denied(request):
    return render_to_response('excerptexport/templates/access_denied.html', context=RequestContext(request))


def index(request):
    return render_to_response('excerptexport/templates/index.html', context=RequestContext(request))


{'fraction_non_alphanumeric': 0.06017441860465116, 'fraction_numerical': 0.0017441860465116279, 'mean_word_length': 6.153846153846154, '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': '3841280', 'n_tokens_mistral': 1012, 'n_tokens_neox': 903, 'n_words': 218}