""" This module holds the django admin of the ``translation`` app. """

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

from .models import TranslatableLanguage, Translation


class TranslatableLanguageAdmin(admin.ModelAdmin):
    """ Admin for TranslatableLanguage. """

    fields = ('language', 'enabled', 'last_modified')
    readonly_fields = ('last_modified',)
    list_display = ('__str__', 'enabled')
    list_filter = ('language', 'enabled')


class TranslationAdmin(admin.ModelAdmin):
    """ Admin for Translation. """

    fields = ('language', 'domain', 'progression', 'last_modified')
    readonly_fields = ('last_modified',)
    list_display = ('__str__', 'display_progression')
    list_filter = ('language',)

    def display_progression(self, obj):
        return "%s%%" % obj.progression
    display_progression.short_description = _('Progression (%)')

admin.site.register(TranslatableLanguage, TranslatableLanguageAdmin)
admin.site.register(Translation, TranslationAdmin)
