# Path: feincms/utils/queryset_transform.py
# class TransformQuerySet(models.query.QuerySet):
#     class TransformManager(models.Manager):
#     def __init__(self, *args, **kwargs):
#     def _clone(self, *args, **kwargs):
#     def transform(self, *fn):
#     def _fetch_all(self):
#         def get_queryset(self):
#         def transform(self, *fn):


from django.conf import settings
from django.contrib import admin
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import Q
from django.utils import translation
from django.utils.translation import gettext_lazy as _
from feincms.utils import queryset_transform
    """
    Mixin with helper methods.
    """

    def _get_translation_object(self, queryset, language_code):
        try:
            return queryset.filter(
                Q(language_code__iexact=language_code)
                | Q(language_code__iexact=short_language_code(language_code))
            ).order_by("-language_code")[0]
        except IndexError:
            try:
                return queryset.filter(
                    Q(language_code__istartswith=settings.LANGUAGE_CODE)
                    | Q(
                        language_code__istartswith=short_language_code(
                            settings.LANGUAGE_CODE
                        )
                    )
                ).order_by("-language_code")[0]
            except IndexError:
                try:
                    return queryset.all()[0]
                except IndexError:
                    raise queryset.model.DoesNotExist

    def get_translation_cache_key(self, language_code=None):
        """Return the cache key used to cache this object's translations so we
        can purge on-demand"""
        if not language_code:

# Path: feincms/utils/queryset_transform.py
# class TransformQuerySet(models.query.QuerySet):
#     class TransformManager(models.Manager):
#     def __init__(self, *args, **kwargs):
#     def _clone(self, *args, **kwargs):
#     def transform(self, *fn):
#     def _fetch_all(self):
#         def get_queryset(self):
#         def transform(self, *fn):


# Path: feincms/translations.py
from django.conf import settings
from django.contrib import admin
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import Q
from django.utils import translation
from django.utils.translation import gettext_lazy as _
from feincms.utils import queryset_transform

    """
    Mixin with helper methods.
    """

    def _get_translation_object(self, queryset, language_code):
        try:
            return queryset.filter(
                Q(language_code__iexact=language_code)
                | Q(language_code__iexact=short_language_code(language_code))
            ).order_by("-language_code")[0]
        except IndexError:
            try:
                return queryset.filter(
                    Q(language_code__istartswith=settings.LANGUAGE_CODE)
                    | Q(
                        language_code__istartswith=short_language_code(
                            settings.LANGUAGE_CODE
                        )
                    )
                ).order_by("-language_code")[0]
            except IndexError:
                try:
                    return queryset.all()[0]
                except IndexError:
                    raise queryset.model.DoesNotExist

    def get_translation_cache_key(self, language_code=None):
        """Return the cache key used to cache this object's translations so we
        can purge on-demand"""
        if not language_code:

            language_code = translation.get_language()