<commit_before>import json

from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.http import HttpResponseBadRequest, HttpResponseForbidden, JsonResponse

from . import models

@login_required
def importer(request):
    response = {}
    # If a post_key is specified in the settings we use
    # it as a "security" measure
    post_key = getattr(settings, "POST_KEY", None)
    if post_key:
        response['POST_KEY'] = post_key
    return render(request, 'importer/index.html', response)

@require_POST
def reset_fake_teams(request):
    print 'done'
    response = {}
    #models.FakeTeams.objects.all().delete()
    status = 200
    return JsonResponse(
        response,
        status=status
    )


@csrf_exempt
@require_POST
def register_formhub_survey(request):

    # If a post_key is specified in the settings we use
    # it as a "security" measure
    post_key = getattr(settings, "POST_KEY", None)

    if post_key:
        if "key" in request.GET:
            if request.GET["key"] != post_key:
                #The request has a key but it doesn't match
                return HttpResponseForbidden()<commit_msg>really remove fake teams when resetting them<commit_after>import json

from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.http import HttpResponseBadRequest, HttpResponseForbidden, JsonResponse

from . import models

@login_required
def importer(request):
    response = {}
    # If a post_key is specified in the settings we use
    # it as a "security" measure
    post_key = getattr(settings, "POST_KEY", None)
    if post_key:
        response['POST_KEY'] = post_key
    return render(request, 'importer/index.html', response)

@require_POST
def reset_fake_teams(request):
    print 'done'
    response = {}
    models.FakeTeams.objects.all().delete()
    status = 200
    return JsonResponse(
        response,
        status=status
    )


@csrf_exempt
@require_POST
def register_formhub_survey(request):

    # If a post_key is specified in the settings we use
    # it as a "security" measure
    post_key = getattr(settings, "POST_KEY", None)

    if post_key:
        if "key" in request.GET:
            if request.GET["key"] != post_key:
                #The request has a key but it doesn't match
                return HttpResponseForbidden()
{'fraction_non_alphanumeric': 0.07896706586826348, 'fraction_numerical': 0.002245508982035928, 'mean_word_length': 3.3891625615763545, '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': '2100884', 'n_tokens_mistral': 786, 'n_tokens_neox': 770, 'n_words': 241}