<commit_before>from django.contrib import admin, messages

from news.models import (APIUser, BlockedEmail, FailedTask, Interest, LocaleStewards, Newsletter,
                         NewsletterGroup, SMSMessage)


class SMSMessageAdmin(admin.ModelAdmin):
    fields = ('message_id', 'vendor_id', 'description')
    list_display = ('message_id', 'vendor_id', 'description')
    list_editable = ('vendor_id',)


class BlockedEmailAdmin(admin.ModelAdmin):
    fields = ('email_domain',)
    list_display = ('email_domain',)


class NewsletterGroupAdmin(admin.ModelAdmin):
    fields = ('title', 'slug', 'description', 'show', 'active', 'newsletters')
    list_display = ('title', 'slug', 'show', 'active')
    list_display_links = ('title', 'slug')
    prepopulated_fields = {"slug": ("title",)}


class LocaleStewardsInline(admin.TabularInline):
    model = LocaleStewards
    fields = ('locale', 'emails')


class InterestAdmin(admin.ModelAdmin):
    fields = ('title', 'interest_id', '_welcome_id', 'default_steward_emails')
    list_display = ('title', 'interest_id', '_welcome_id', 'default_steward_emails')
    list_editable = ('interest_id', '_welcome_id', 'default_steward_emails')
    prepopulated_fields = {'interest_id': ('title',)}
    inlines = [LocaleStewardsInline]


class APIUserAdmin(admin.ModelAdmin):
    list_display = ('name', 'enabled')


class NewsletterAdmin(admin.ModelAdmin):
    fields = ('title', 'slug', 'vendor_id', 'welcome', 'confirm_message',
              'description', 'languages', 'show', 'order', 'active',
              'requires_double_optin', 'private')
    list_display = ('order', 'title', 'slug', 'vendor_id', 'welcome',
                    'confirm_message', 'languages', 'show', 'active',
                    'requires_double_optin', 'private')
    list_display_links = ('title', 'slug')
    list_editable = ('order', 'show', 'active', 'requires_double_optin', 'private')
    list_filter = ('show', 'active', 'requires_double_optin', 'private')
    prepopulated_fields = {"slug": ("title",)}
    search_fields = ('title', 'slug', 'description', 'vendor_id')


class TaskNameFilter(admin.SimpleListFilter):
    """Filter to provide nicer names for task names."""
    title = 'task name'
    parameter_name = 'name'

    def lookups(self, request, model_admin):
        qs = model_admin.queryset(request)
        names = qs.values_list('name', flat=True).distinct().order_by('name')
        return [(name, name.rsplit('.', 1)[1].replace('_', ' ')) for name in names]
<commit_msg>Fix bug in FailedTask admin<commit_after>from django.contrib import admin, messages

from news.models import (APIUser, BlockedEmail, FailedTask, Interest, LocaleStewards, Newsletter,
                         NewsletterGroup, SMSMessage)


class SMSMessageAdmin(admin.ModelAdmin):
    fields = ('message_id', 'vendor_id', 'description')
    list_display = ('message_id', 'vendor_id', 'description')
    list_editable = ('vendor_id',)


class BlockedEmailAdmin(admin.ModelAdmin):
    fields = ('email_domain',)
    list_display = ('email_domain',)


class NewsletterGroupAdmin(admin.ModelAdmin):
    fields = ('title', 'slug', 'description', 'show', 'active', 'newsletters')
    list_display = ('title', 'slug', 'show', 'active')
    list_display_links = ('title', 'slug')
    prepopulated_fields = {"slug": ("title",)}


class LocaleStewardsInline(admin.TabularInline):
    model = LocaleStewards
    fields = ('locale', 'emails')


class InterestAdmin(admin.ModelAdmin):
    fields = ('title', 'interest_id', '_welcome_id', 'default_steward_emails')
    list_display = ('title', 'interest_id', '_welcome_id', 'default_steward_emails')
    list_editable = ('interest_id', '_welcome_id', 'default_steward_emails')
    prepopulated_fields = {'interest_id': ('title',)}
    inlines = [LocaleStewardsInline]


class APIUserAdmin(admin.ModelAdmin):
    list_display = ('name', 'enabled')


class NewsletterAdmin(admin.ModelAdmin):
    fields = ('title', 'slug', 'vendor_id', 'welcome', 'confirm_message',
              'description', 'languages', 'show', 'order', 'active',
              'requires_double_optin', 'private')
    list_display = ('order', 'title', 'slug', 'vendor_id', 'welcome',
                    'confirm_message', 'languages', 'show', 'active',
                    'requires_double_optin', 'private')
    list_display_links = ('title', 'slug')
    list_editable = ('order', 'show', 'active', 'requires_double_optin', 'private')
    list_filter = ('show', 'active', 'requires_double_optin', 'private')
    prepopulated_fields = {"slug": ("title",)}
    search_fields = ('title', 'slug', 'description', 'vendor_id')


class TaskNameFilter(admin.SimpleListFilter):
    """Filter to provide nicer names for task names."""
    title = 'task name'
    parameter_name = 'name'

    def lookups(self, request, model_admin):
        qs = model_admin.get_queryset(request)
        names = qs.values_list('name', flat=True).distinct().order_by('name')
        return [(name, name.rsplit('.', 1)[1].replace('_', ' ')) for name in names]

{'fraction_non_alphanumeric': 0.1609331751680506, 'fraction_numerical': 0.0007908264136022143, 'mean_word_length': 4.433941997851773, 'pattern_counts': {'":': 4, '<': 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': '6666334', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1551, 'n_words': 340}