<commit_before>import json

from django.shortcuts import render, get_object_or_404
from django.contrib.auth.decorators import permission_required
from django.core.exceptions import PermissionDenied
from django.views.decorators.vary import vary_on_headers
from django.http import HttpResponseBadRequest

from wagtail.wagtailimages.models import get_image_model
from wagtail.wagtailimages.forms import get_image_form_for_multi


@permission_required('wagtailimages.add_image')
@vary_on_headers('X-Requested-With')
def add(request):
    ImageForm = get_image_form_for_multi()
    ImageModel = get_image_model()

    if request.POST and request.is_ajax():
        if not request.FILES:
            return HttpResponseBadRequest("Must upload a file")
        else:
            image = ImageModel(uploaded_by_user=request.user,  title=request.FILES['files[]'].name, file=request.FILES['files[]'])
            image.save()
            form = ImageForm(instance=image, prefix='image-%d'%image.id)

            return render(request, 'wagtailimages/multiple/edit_form.html', {
                'image': image,
                'form': form
            })
    else:
        pass

    return render(request, 'wagtailimages/multiple/add.html', {})


@permission_required('wagtailadmin.access_admin')  # more specific permission tests are applied within the view
def edit(request, image_id, callback=None):
    Image = get_image_model()
    ImageForm = get_image_form_for_multi()

    image = get_object_or_404(Image, id=image_id)

    if not image.is_editable_by_user(request.user):
        raise PermissionDenied
<commit_msg>ImageModel => Image<commit_after>import json

from django.shortcuts import render, get_object_or_404
from django.contrib.auth.decorators import permission_required
from django.core.exceptions import PermissionDenied
from django.views.decorators.vary import vary_on_headers
from django.http import HttpResponseBadRequest

from wagtail.wagtailimages.models import get_image_model
from wagtail.wagtailimages.forms import get_image_form_for_multi


@permission_required('wagtailimages.add_image')
@vary_on_headers('X-Requested-With')
def add(request):
    Image = get_image_model()
    ImageForm = get_image_form_for_multi()

    if request.POST and request.is_ajax():
        if not request.FILES:
            return HttpResponseBadRequest("Must upload a file")
        else:
            image = Image(uploaded_by_user=request.user,  title=request.FILES['files[]'].name, file=request.FILES['files[]'])
            image.save()
            form = ImageForm(instance=image, prefix='image-%d'%image.id)

            return render(request, 'wagtailimages/multiple/edit_form.html', {
                'image': image,
                'form': form
            })
    else:
        pass

    return render(request, 'wagtailimages/multiple/add.html', {})


@permission_required('wagtailadmin.access_admin')  # more specific permission tests are applied within the view
def edit(request, image_id, callback=None):
    Image = get_image_model()
    ImageForm = get_image_form_for_multi()

    image = get_object_or_404(Image, id=image_id)

    if not image.is_editable_by_user(request.user):
        raise PermissionDenied

{'fraction_non_alphanumeric': 0.09378881987577639, 'fraction_numerical': 0.0037267080745341614, 'mean_word_length': 3.8582202111613877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2387164', 'n_tokens_mistral': 974, 'n_tokens_neox': 933, 'n_words': 197}