<commit_before># coding: utf-8

from __future__ import unicode_literals
import json

from django.apps import apps
from django.contrib.messages.views import SuccessMessageMixin
from django.contrib import messages
from django.http import JsonResponse
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse_lazy
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import UpdateView, CreateView, DeleteView
from django.views.generic.list import ListView
from pygments import highlight
from pygments.lexers import JsonLexer
from pygments.formatters import HtmlFormatter

from .models import App, Boite


# Boîtes

class BoiteListView(ListView):
    model = Boite

    def get_queryset(self):
        boites = Boite.objects.filter(qrcode=None)
        for boite in boites:
            boite.generate_qrcode()
            boite.save()

        return Boite.objects.filter(user=self.request.user).order_by("created_date")


def json_view(request, api_key):
    boite = get_object_or_404(Boite, api_key=api_key)
    boite.last_connection = request.META.get("REMOTE_ADDR", "")
    boite.save()
    return JsonResponse(boite.get_apps_dictionary(), safe=False)

def create_app_view(request, pk):
    boite = get_object_or_404(Boite, pk=pk)

    apps_list = []
    for model in apps.get_models():
        if issubclass(model, App):
            app_instances = model.objects.filter(boite=boite)
            verbose_name =  model._meta.verbose_name.title()
            if not app_instances:
                apps_list.append({'verbose_name':verbose_name[16:], 'pk':'create', 'app_label': model._meta.app_label})

    return render(request, 'boites/boite_create_app.html', {'boite': boite, 'boite_id': boite.id, 'apps': apps_list})


def apps_view(request, pk):
    boite = get_object_or_404(Boite, pk=pk)

    apps_list = []
    enabled_apps = 0
    for model in apps.get_models():<commit_msg>Taking into account @vrialland requested changes<commit_after># coding: utf-8

from __future__ import unicode_literals
import json

from django.apps import apps
from django.contrib.messages.views import SuccessMessageMixin
from django.contrib import messages
from django.http import JsonResponse
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse_lazy
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import UpdateView, CreateView, DeleteView
from django.views.generic.list import ListView
from pygments import highlight
from pygments.lexers import JsonLexer
from pygments.formatters import HtmlFormatter

from .models import App, Boite


# Boîtes

class BoiteListView(ListView):
    model = Boite

    def get_queryset(self):
        boites = Boite.objects.filter(qrcode=None)
        for boite in boites:
            boite.generate_qrcode()
            boite.save()

        return Boite.objects.filter(user=self.request.user).order_by("created_date")


def json_view(request, api_key):
    boite = get_object_or_404(Boite, api_key=api_key)
    boite.last_connection = request.META.get("REMOTE_ADDR", "")
    boite.save()
    return JsonResponse(boite.get_apps_dictionary(), safe=False)

def create_app_view(request, pk):
    boite = get_object_or_404(Boite, pk=pk, user=request.user)

    apps_list = []
    for model in apps.get_models():
        if issubclass(model, App):
            app_instances = model.objects.filter(boite=boite)
            verbose_name =  model._meta.verbose_name.title()
            if not app_instances:
                apps_list.append({'verbose_name':verbose_name[16:], 'pk':'create', 'app_label': model._meta.app_label})

    return render(request, 'boites/boite_create_app.html', {'boite': boite, 'boite_id': boite.id, 'apps': apps_list})


def apps_view(request, pk):
    boite = get_object_or_404(Boite, pk=pk, user=request.user)

    apps_list = []
    enabled_apps = 0
    for model in apps.get_models():
{'fraction_non_alphanumeric': 0.09501595875276209, 'fraction_numerical': 0.007856616744414437, 'mean_word_length': 4.130982367758186, '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': '7008434', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1275, 'n_words': 300}