<commit_before># -*- coding: utf-8 -*-

from django.contrib import admin
from .models import LandingContent


class LandingContentAdmin(admin.ModelAdmin):
    list_display = ('name', 'content_en')
    #list_display_links = ('name')

    #list_filter = (HasTranslationFilter(lang)
    #               for lang, lang_name in settings.LANGUAGES)
    ordering = ('name',)
    search_fields = ('name', 'content_en',
                     'content_en-us', 'content_en-gb',
                     'content_fr')


admin.site.register(LandingContent, LandingContentAdmin)<commit_msg>Fix the admin 500 error http://dev.1flow.net/webapps/1flow/group/94/ (and enhance the transmeta change list).<commit_after># -*- coding: utf-8 -*-

from django.contrib import admin
from django.conf import settings
from .models import LandingContent

TRUNCATE_LENGTH = 50

content_fields_names = tuple(('content_' + code)
                             for code, lang
                             in settings.LANGUAGES)
content_fields_displays = tuple((field + '_display')
                                for field in content_fields_names)


class LandingContentAdmin(admin.ModelAdmin):
    list_display = ('name', ) + content_fields_displays
    #list_display_links = ('name')

    #list_filter = (HasTranslationFilter(lang)
    #               for lang, lang_name in settings.LANGUAGES)
    ordering = ('name',)
    search_fields = ('name', ) + content_fields_names


def truncated(cls, field_name):
    def wrapped(self, obj):
        value = getattr(obj, field_name)
        return value[:TRUNCATE_LENGTH] + (value[TRUNCATE_LENGTH:] and u'…')

    wrapped.short_description = cls._meta.get_field_by_name(
        field_name)[0].verbose_name
    wrapped.admin_order_field = field_name
    return wrapped

for attr, attr_name in zip(content_fields_names,
                           content_fields_displays):
    setattr(LandingContentAdmin, attr_name,
            truncated(LandingContent, attr))


admin.site.register(LandingContent, LandingContentAdmin)
{'fraction_non_alphanumeric': 0.10320987654320987, 'fraction_numerical': 0.005925925925925926, 'mean_word_length': 2.9881889763779528, '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': '5736932', 'n_tokens_mistral': 607, 'n_tokens_neox': 580, 'n_words': 129}