'''Plugins admin class
'''
from easy_thumbnails.files import get_thumbnailer
from django.contrib import admin
from django.utils.html import format_html

from .models import Gallery, GalleryItem

admin.site.register(Gallery)



@admin.register(GalleryItem)
class GalleryItemAdmin(admin.ModelAdmin):
    '''Admin class for Gallery item
    '''

    def image_tag(self, obj):
        ''' Defines a field for django admin
        '''

        options = {'size': (100, 100), 'crop': True}
        thumb_url = get_thumbnailer(obj.image).get_thumbnail(options).url
        return format_html('<img src="{}" />'.format(thumb_url))

    image_tag.short_description = 'Image'

    list_display = ['image_tag', 'image', 'gallery']

    list_filter = ('gallery',)

'''Plugins admin class
'''
from easy_thumbnails.files import get_thumbnailer
from django.contrib import admin
from django.utils.html import format_html

from .models import Gallery, GalleryItem

admin.site.register(Gallery)



@admin.register(GalleryItem)
class GalleryItemAdmin(admin.ModelAdmin):
    '''Admin class for Gallery item
    '''

    def image_tag(self, obj):
        ''' Defines a field for django admin
        '''

        options = {'size': (100, 100), 'crop': True}
        thumb_url = get_thumbnailer(obj.image).get_thumbnail(options).url
        return format_html('<img src="{}" />'.format(thumb_url))

    image_tag.short_description = 'Image'

    list_display = ['image_tag', 'image', 'gallery']

    list_filter = ('gallery',)

Plugins admin class Admin class for Gallery item Defines a field for django admin