<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from hvad.admin import TranslatableAdmin
from cms.admin.placeholderadmin import PlaceholderAdmin

from blogit.models import AuthorLink, Author, Category, Tag, TaggedPost, Post
from blogit.utils.image import thumb


class AuthorLinkInline(admin.TabularInline):
    model = AuthorLink
    extra = 0


class AuthorAdmin(TranslatableAdmin, PlaceholderAdmin):
    list_display = ('get_full_name', 'slug', 'all_translations', 'get_image')
    inlines = (AuthorLinkInline,)

    def __init__(self, *args, **kwargs):
        super(AuthorAdmin, self).__init__(*args, **kwargs)
        self.fieldsets = (
            (None, {
                'fields': ('slug', 'user'),
                'description': _(
                    'These fields are the same across all languages.'),
            }),
            (_('Personal Info'), {
                'fields': ('first_name', 'last_name', 'email', 'picture'),
                'description': _(
                    'These fields are the same across all languages.'),
            }),
            (None, {
                'fields': ('description',),
            }),
            (_('Bio'), {
                'fields': ('bio',),
                'classes': ('plugin-holder', 'plugin-holder-nopage'),
            }),
        )

    def get_image(self, obj):
        # Returns a thumbnail to display in list_display.
        if obj.picture:
            return '<img src="{}">'.format(thumb(obj.picture, '72x72'))
        return None
    get_image.short_description = _('picture')
    get_image.allow_tags = True

    def get_full_name(self, obj):
        # Returns authors full name.
        return obj.get_full_name()
    get_full_name.short_description = _('full name')


class CategoryAdmin(TranslatableAdmin, PlaceholderAdmin):
    list_display = (
        'get_title', 'get_slug', 'date_created', 'last_modified',
        'all_translations')
    list_filter = ('date_created', 'last_modified')
    readonly_fields = ('last_modified',)

    def __init__(self, *args, **kwargs):
        super(CategoryAdmin, self).__init__(*args, **kwargs)
        self.prepopulated_fields = {'slug': ('title',)}
        self.fieldsets = (
            (None, {
                'fields': ('title', 'slug'),
            }),
            (_('Common Settings'), {
                'fields': ('parent',),
                'description': _(
                    'These fields are the same across all languages.'),
            }),
            (_('Date Information'), {
                'fields': ('date_created', 'last_modified'),
                'classes': ('collapse',),
                'description': _(
                    'These fields are the same across all languages.'),
            }),
        )

    def get_title(self, obj):
        # Returns translated title field.
        return obj.__str__()
    get_title.short_description = _('title')

    def get_slug(self, obj):
        # Returns translated slug field.
        return obj.get_slug()
    get_title.short_description = _('slug')


class TaggedPostInline(admin.TabularInline):
    model = TaggedPost
    extra = 0


class TagAdmin(admin.ModelAdmin):
    inlines = (TaggedPostInline,)


class PostAdmin(TranslatableAdmin, PlaceholderAdmin):
    list_display = (
        'get_title', 'get_slug', 'date_published', 'author',
        'all_translations', 'get_image', 'get_is_public')
    list_filter = ('date_published', 'date_created', 'last_modified', 'author')
    readonly_fields = ('date_created', 'last_modified',)
    actions = ['make_public', 'make_hidden']

    def __init__(self, *args, **kwargs):
        super(PostAdmin, self).__init__(*args, **kwargs)
        self.prepopulated_fields = {'slug': ('title',)}
        self.fieldsets = (
            (None, {
                'fields': ('title', 'slug', 'is_public'),
            }),<commit_msg>Admin tag fixup<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from hvad.admin import TranslatableAdmin
from cms.admin.placeholderadmin import PlaceholderAdmin

from blogit.models import AuthorLink, Author, Category, Tag, TaggedPost, Post
from blogit.utils.image import thumb


class AuthorLinkInline(admin.TabularInline):
    model = AuthorLink
    extra = 0


class AuthorAdmin(TranslatableAdmin, PlaceholderAdmin):
    list_display = ('get_full_name', 'slug', 'all_translations', 'get_image')
    inlines = (AuthorLinkInline,)

    def __init__(self, *args, **kwargs):
        super(AuthorAdmin, self).__init__(*args, **kwargs)
        self.fieldsets = (
            (None, {
                'fields': ('slug', 'user'),
                'description': _(
                    'These fields are the same across all languages.'),
            }),
            (_('Personal Info'), {
                'fields': ('first_name', 'last_name', 'email', 'picture'),
                'description': _(
                    'These fields are the same across all languages.'),
            }),
            (None, {
                'fields': ('description',),
            }),
            (_('Bio'), {
                'fields': ('bio',),
                'classes': ('plugin-holder', 'plugin-holder-nopage'),
            }),
        )

    def get_image(self, obj):
        # Returns a thumbnail to display in list_display.
        if obj.picture:
            return '<img src="{}">'.format(thumb(obj.picture, '72x72'))
        return None
    get_image.short_description = _('picture')
    get_image.allow_tags = True

    def get_full_name(self, obj):
        # Returns authors full name.
        return obj.get_full_name()
    get_full_name.short_description = _('full name')


class CategoryAdmin(TranslatableAdmin, PlaceholderAdmin):
    list_display = (
        'get_title', 'get_slug', 'date_created', 'last_modified',
        'all_translations')
    list_filter = ('date_created', 'last_modified')
    readonly_fields = ('last_modified',)

    def __init__(self, *args, **kwargs):
        super(CategoryAdmin, self).__init__(*args, **kwargs)
        self.prepopulated_fields = {'slug': ('title',)}
        self.fieldsets = (
            (None, {
                'fields': ('title', 'slug'),
            }),
            (_('Common Settings'), {
                'fields': ('parent',),
                'description': _(
                    'These fields are the same across all languages.'),
            }),
            (_('Date Information'), {
                'fields': ('date_created', 'last_modified'),
                'classes': ('collapse',),
                'description': _(
                    'These fields are the same across all languages.'),
            }),
        )

    def get_title(self, obj):
        # Returns translated title field.
        return obj.__str__()
    get_title.short_description = _('title')

    def get_slug(self, obj):
        # Returns translated slug field.
        return obj.get_slug()
    get_title.short_description = _('slug')


class TaggedPostInline(admin.TabularInline):
    model = TaggedPost
    extra = 0


class TagAdmin(admin.ModelAdmin):
    inlines = (TaggedPostInline,)
    list_display = ('name', 'slug')
    ordering = ('name', 'slug')
    search_fields = ('name',)
    prepopulated_fields = {'slug': ('name',)}


class PostAdmin(TranslatableAdmin, PlaceholderAdmin):
    list_display = (
        'get_title', 'get_slug', 'date_published', 'author',
        'all_translations', 'get_image', 'get_is_public')
    list_filter = ('date_published', 'date_created', 'last_modified', 'author')
    readonly_fields = ('date_created', 'last_modified',)
    actions = ['make_public', 'make_hidden']

    def __init__(self, *args, **kwargs):
        super(PostAdmin, self).__init__(*args, **kwargs)
        self.prepopulated_fields = {'slug': ('title',)}
        self.fieldsets = (
            (None, {
                'fields': ('title', 'slug', 'is_public'),
            }),
{'fraction_non_alphanumeric': 0.1378927911275416, 'fraction_numerical': 0.001725200246457178, 'mean_word_length': 2.3830762817840765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2589138', 'n_tokens_mistral': 2308, 'n_tokens_neox': 2268, 'n_words': 535}