<commit_before>from django.contrib import admin
from django.contrib.admin.filterspecs import FilterSpec

from .models import License, Version


class LicenseAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'builtin', 'url')
    list_filter = ('builtin',)
    ordering = ('builtin',)


class BuiltinFilterSpec(FilterSpec):
    """Let us filter licenses by builtin/non-builtin."""

    def __init__(self, field, request, params, model, model_admin):
        super(BuiltinFilterSpec, self).__init__(field, request, params,
                                                model, model_admin)
        self.lookup_kwarg = '%s__gt' % field.name
        self.lookup_val = request.GET.get(self.lookup_kwarg, False)

    def choices(self, cl):
        yield {'selected': not self.lookup_val,
               'query_string': cl.get_query_string({}, [self.lookup_kwarg]),
               'display': 'All licenses'}
        yield {'selected': self.lookup_val,
               'query_string': cl.get_query_string({self.lookup_kwarg: 0}),
               'display': 'Built-in licenses'}


FilterSpec.filter_specs.insert(0,
    (lambda f: f.model is License, BuiltinFilterSpec))

admin.site.register(License, LicenseAdmin)
admin.site.register(Version)<commit_msg>filterspecs go away in the new Django admin and no one used this code<commit_after>from django.contrib import admin

from .models import License, Version


class LicenseAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'builtin', 'url')
    list_filter = ('builtin',)
    ordering = ('builtin',)


admin.site.register(License, LicenseAdmin)
admin.site.register(Version)
{'fraction_non_alphanumeric': 0.12323727774371551, 'fraction_numerical': 0.001226241569589209, 'mean_word_length': 3.446866485013624, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4295161', 'n_tokens_mistral': 470, 'n_tokens_neox': 468, 'n_words': 118}