# Path: admin_interface/cache.py
# def del_cached_active_theme():
#     app_cache().delete("admin_interface_theme")
# 
# Path: admin_interface/compat.py
# def FileExtensionValidator(*args, **kwargs):
#     def noop(*args, **kwargs):


from admin_interface.cache import del_cached_active_theme
from admin_interface.compat import FileExtensionValidator, force_str, gettext_lazy as _
from colorfield.fields import ColorField
from django.db import models
from django.db.models.signals import post_delete, post_save, pre_save
from six import python_2_unicode_compatible
                obj = Theme.objects.get(name=instance.name)
                if obj:
                    instance.pk = obj.pk
            except Theme.DoesNotExist:
                pass

    @staticmethod
    def get_active_theme():
        objs_manager = Theme.objects
        objs_active_qs = objs_manager.filter(active=True)
        objs_active_ls = list(objs_active_qs)
        objs_active_count = len(objs_active_ls)

        if objs_active_count == 0:
            obj = objs_manager.all().first()
            if obj:
                obj.set_active()
            else:
                obj = objs_manager.create()

        elif objs_active_count == 1:
            obj = objs_active_ls[0]

        elif objs_active_count > 1:
            obj = objs_active_ls[-1]
            obj.set_active()

        return obj

    name = models.CharField(

# Path: admin_interface/cache.py
# def del_cached_active_theme():
#     app_cache().delete("admin_interface_theme")
# 
# Path: admin_interface/compat.py
# def FileExtensionValidator(*args, **kwargs):
#     def noop(*args, **kwargs):


# Path: admin_interface/models.py
from admin_interface.cache import del_cached_active_theme
from admin_interface.compat import FileExtensionValidator, force_str, gettext_lazy as _
from colorfield.fields import ColorField
from django.db import models
from django.db.models.signals import post_delete, post_save, pre_save
from six import python_2_unicode_compatible

                obj = Theme.objects.get(name=instance.name)
                if obj:
                    instance.pk = obj.pk
            except Theme.DoesNotExist:
                pass

    @staticmethod
    def get_active_theme():
        objs_manager = Theme.objects
        objs_active_qs = objs_manager.filter(active=True)
        objs_active_ls = list(objs_active_qs)
        objs_active_count = len(objs_active_ls)

        if objs_active_count == 0:
            obj = objs_manager.all().first()
            if obj:
                obj.set_active()
            else:
                obj = objs_manager.create()

        elif objs_active_count == 1:
            obj = objs_active_ls[0]

        elif objs_active_count > 1:
            obj = objs_active_ls[-1]
            obj.set_active()

        return obj

    name = models.CharField(

        unique=True, max_length=50, default="Django", verbose_name=_("name")