<commit_before>"""Admin registrations for Sites."""

from django.contrib import admin
from .models import Site, Language

class LanguageAdmin(admin.ModelAdmin):
    list_display = ('name', 'code', 'language_code', 'country_code', 'display_country')

class SiteAdmin(admin.ModelAdmin):
    list_display = ('title', 'clickable_url', 'author', 'visible', 'featured')

    def make_visible(modeladmin, request, queryset):
        queryset.update(visible=True)

    make_visible.short_description = "Show selected sites"

    def make_invisible(modeladmin, request, queryset):
        queryset.update(visible=False)

    make_invisible.short_description = "Hide selected sites"

    actions = [make_visible, make_invisible]

admin.site.register(Site, SiteAdmin)
admin.site.register(Language, LanguageAdmin)<commit_msg>Order languages in admin form<commit_after>"""Admin registrations for Sites."""

from django.contrib import admin
from django.forms import ModelForm, ModelMultipleChoiceField
from .models import Site, Language

class SiteAdminForm(ModelForm):
    languages = ModelMultipleChoiceField(queryset=Language.objects.order_by('name'))

    class Meta:
        model = Site
        fields = '__all__'

class LanguageAdmin(admin.ModelAdmin):
    list_display = ('name', 'code', 'language_code', 'country_code', 'display_country')

class SiteAdmin(admin.ModelAdmin):
    list_display = ('title', 'clickable_url', 'author', 'visible', 'featured')
    form = SiteAdminForm

    def make_visible(modeladmin, request, queryset):
        queryset.update(visible=True)

    make_visible.short_description = "Show selected sites"

    def make_invisible(modeladmin, request, queryset):
        queryset.update(visible=False)

    make_invisible.short_description = "Hide selected sites"

    actions = [make_visible, make_invisible]

admin.site.register(Site, SiteAdmin)
admin.site.register(Language, LanguageAdmin)
{'fraction_non_alphanumeric': 0.11041339612768185, 'fraction_numerical': 0.0, 'mean_word_length': 5.228013029315961, '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': '7079694', 'n_tokens_mistral': 545, 'n_tokens_neox': 531, 'n_words': 128}