<commit_before>from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
from imageledger import models
from django.contrib.admin.widgets import AdminFileWidget
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe


class ImageAdmin(admin.ModelAdmin):
    fields = ( 'image_tag', 'title', 'provider', 'license', 'license_version')
    readonly_fields = ('image_tag',)

class ImageInline(admin.TabularInline):
    model = models.List.images.through

class ListAdmin(admin.ModelAdmin):
    inlines = [ ImageInline, ]
    exclude = ('images',)

admin.site.register(models.List, ListAdmin)
admin.site.register(models.Image, ImageAdmin)<commit_msg>[#148] Enhancements for list admin<commit_after>from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
from imageledger import models
from django.contrib.admin.widgets import AdminFileWidget
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe


class ImageAdmin(admin.ModelAdmin):
    list_display = ('title', 'creator', 'provider', 'created_on', 'last_synced_with_source')
    fields = ( 'image_tag', 'title', 'provider', 'license', 'license_version', 'created_on', 'last_synced_with_source',
              'foreign_landing_url', 'foreign_identifier')
    readonly_fields = ('image_tag', 'created_on', 'last_synced_with_source', )

class ListAdmin(admin.ModelAdmin):
    empty_value_display = '-blank-'
    list_display = ('title', 'owner', 'num_images', 'is_public', 'created_on', 'updated_on')
    readonly_fields = ('images', 'slug')
    def num_images(self, obj):
        return obj.images.all().count()

#    filter_horizontal = ['images']
admin.site.register(models.List, ListAdmin)
admin.site.register(models.Image, ImageAdmin)
{'fraction_non_alphanumeric': 0.1186623516720604, 'fraction_numerical': 0.0016181229773462784, 'mean_word_length': 5.794871794871795, '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': '1507801', 'n_tokens_mistral': 550, 'n_tokens_neox': 543, 'n_words': 124}