# Path: libre/apps/icons/models.py
# class Icon(models.Model):
#     _cache = {}
# 
#     name = models.CharField(max_length=48, verbose_name=_(u'name'), unique=True)
#     label = models.CharField(max_length=48, verbose_name=_(u'label'), blank=True)
#     icon_file = models.FileField(upload_to='icons', verbose_name='file')
# 
#     def __unicode__(self):
#         return self.label or self.name
# 
#     def compose(self, as_base64=False):
#         try:
#             self.__class__._cache.setdefault(self.pk, {})
#             return self.__class__._cache[self.pk][as_base64]
#         except KeyError:
#             image = PIL.Image.open(self.icon_file.file)
#             output = StringIO()
#             image.save(output, 'PNG')
#             contents = output.getvalue()
#             output.close()
#             if as_base64:
#                 contents = 'data:image/png;base64,%s' % base64.b64encode(contents)
#             self.__class__._cache.setdefault(self.pk, {})
#             self.__class__._cache[self.pk][as_base64] = contents
#             return contents
# 
#     def compose_base64(self):
#         return self.compose(as_base64=True)
# 
#     def get_absolute_url(self):
#         return reverse('display', args=[self.name])
# 
#     class Meta:
#         verbose_name = _(u'icon')
#         verbose_name_plural = _(u'icons')
#         ordering = ['label', 'name']


from django.contrib import admin
from .models import Icon
from __future__ import absolute_import




class IconAdmin(admin.ModelAdmin):
    list_display = ('name', 'label', 'icon_file')



# Path: libre/apps/icons/models.py
# class Icon(models.Model):
#     _cache = {}
# 
#     name = models.CharField(max_length=48, verbose_name=_(u'name'), unique=True)
#     label = models.CharField(max_length=48, verbose_name=_(u'label'), blank=True)
#     icon_file = models.FileField(upload_to='icons', verbose_name='file')
# 
#     def __unicode__(self):
#         return self.label or self.name
# 
#     def compose(self, as_base64=False):
#         try:
#             self.__class__._cache.setdefault(self.pk, {})
#             return self.__class__._cache[self.pk][as_base64]
#         except KeyError:
#             image = PIL.Image.open(self.icon_file.file)
#             output = StringIO()
#             image.save(output, 'PNG')
#             contents = output.getvalue()
#             output.close()
#             if as_base64:
#                 contents = 'data:image/png;base64,%s' % base64.b64encode(contents)
#             self.__class__._cache.setdefault(self.pk, {})
#             self.__class__._cache[self.pk][as_base64] = contents
#             return contents
# 
#     def compose_base64(self):
#         return self.compose(as_base64=True)
# 
#     def get_absolute_url(self):
#         return reverse('display', args=[self.name])
# 
#     class Meta:
#         verbose_name = _(u'icon')
#         verbose_name_plural = _(u'icons')
#         ordering = ['label', 'name']


# Path: libre/apps/icons/admin.py
from django.contrib import admin
from .models import Icon

from __future__ import absolute_import




class IconAdmin(admin.ModelAdmin):
    list_display = ('name', 'label', 'icon_file')



admin.site.register(Icon, IconAdmin)