<commit_before>from django.contrib import admin

from announcements.models import Announcement


class AnnouncementAdmin(admin.ModelAdmin):
    list_display = ['__unicode__', 'is_visible']
    exclude = ['created']
    readonly_fields = ['creator']

    def is_visible(self, obj):
        visible = obj.is_visible()
        if visible and obj.show_until:
            return 'Yes (until %s)' % obj.show_until
        elif visible:
            return 'Yes (always)'
        return ''
    is_visible.short_description = 'Visible?'

    def save_model(self, request, obj, form, change):
        if not obj.pk:
            obj.creator = request.user
        obj.save()


admin.site.register(Announcement, AnnouncementAdmin)
<commit_msg>making it easier to work with announcements by adding filters and showing more data upfront<commit_after>from django.contrib import admin

from announcements.models import Announcement


class AnnouncementAdmin(admin.ModelAdmin):
    list_display = ['__unicode__', 'group', 'locale', 'creator', 'is_visible']
    exclude = ['created']
    readonly_fields = ['creator']
    date_hierarchy = 'created'
    list_filter = ['created', 'group', 'locale']
    search_fields = ['creator__username']

    def is_visible(self, obj):
        visible = obj.is_visible()
        if visible and obj.show_until:
            return 'Yes (until %s)' % obj.show_until
        elif visible:
            return 'Yes (always)'
        return ''
    is_visible.short_description = 'Visible?'

    def save_model(self, request, obj, form, change):
        if not obj.pk:
            obj.creator = request.user
        obj.save()


admin.site.register(Announcement, AnnouncementAdmin)

{'fraction_non_alphanumeric': 0.10638297872340426, 'fraction_numerical': 0.0, 'mean_word_length': 3.0405727923627683, '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': '5540137', 'n_tokens_mistral': 491, 'n_tokens_neox': 477, 'n_words': 131}