# Path: elephantblog/models.py
# class Category(models.Model, translations.TranslatedObjectMixin):
#     """
#     Category is language-aware and connected to the Entry model via
#     a many to many relationship.
#     """
# 
#     ordering = models.SmallIntegerField(_("ordering"), default=0)
# 
#     objects = translations.TranslatedObjectManager()
# 
#     class Meta:
#         verbose_name = _("category")
#         verbose_name_plural = _("categories")
#         ordering = ["ordering"]
# 
#     def __str__(self):
#         try:
#             translation = self.translation
#         except models.ObjectDoesNotExist:
#             return gettext("Unnamed category")
# 
#         if translation:
#             return "%s" % translation
# 
#         return gettext("Unnamed category")
# 
# class Entry(Base, ContentModelMixin):
#     is_active = models.BooleanField(_("is active"), default=True, db_index=True)
#     is_featured = models.BooleanField(_("is featured"), default=False, db_index=True)
# 
#     title = models.CharField(_("title"), max_length=100)
#     slug = models.SlugField(_("slug"), max_length=100, unique_for_date="published_on")
#     author = models.ForeignKey(
#         getattr(settings, "AUTH_USER_MODEL", "auth.User"),
#         on_delete=models.CASCADE,
#         related_name="blogentries",
#         limit_choices_to={"is_staff": True},
#         verbose_name=_("author"),
#     )
#     published_on = models.DateTimeField(
#         _("published on"),
#         blank=True,
#         null=True,
#         default=timezone.now,
#         db_index=True,
#         help_text=_("Will be filled in automatically when entry gets published."),
#     )
#     last_changed = models.DateTimeField(_("last change"), auto_now=True, editable=False)
# 
#     categories = models.ManyToManyField(
#         Category, verbose_name=_("categories"), related_name="blogentries", blank=True
#     )
# 
#     objects = EntryManager()
# 
#     class Meta:
#         get_latest_by = "published_on"
#         ordering = ["-published_on"]
#         verbose_name = _("entry")
#         verbose_name_plural = _("entries")
# 
#     def __str__(self):
#         return self.title
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self._old_is_active = self.is_active
# 
#     def save(self, *args, **kwargs):
#         if self.is_active and not self.published_on:
#             self.published_on = timezone.now()
# 
#         super().save(*args, **kwargs)
# 
#     save.alters_data = True
# 
#     def get_absolute_url(self):
#         # The view/template layer always works with visitors' local time.
#         # Therefore, also generate localtime URLs, otherwise visitors will
#         # hit 404s on blog entry URLs generated for them. Unfortunately, this
#         # also means that you cannot send a permalink around half the globe
#         # and expect it to work...
#         # https://code.djangoproject.com/ticket/18794
#         if settings.USE_TZ:
#             pub_date = timezone.localtime(self.published_on)
#         else:
#             pub_date = self.published_on
# 
#         return reverse(
#             "elephantblog_entry_detail",
#             kwargs={
#                 "year": pub_date.strftime("%Y"),
#                 "month": pub_date.strftime("%m"),
#                 "day": pub_date.strftime("%d"),
#                 "slug": self.slug,
#             },
#         )
# 
#     @classmethod
#     def register_extension(cls, register_fn):
#         from .modeladmins import EntryAdmin
# 
#         register_fn(cls, EntryAdmin)
# 
# Path: elephantblog/utils.py
# def entry_list_lookup_related(entry_qs):
#     LookupClass.lookup(entry_qs)


from django.conf import settings
from django.contrib.auth import get_user_model
from django.core import paginator
from django.core.exceptions import FieldDoesNotExist
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.utils.translation import get_language
from django.views.generic import dates
from feincms.module.mixins import ContentObjectMixin
from elephantblog.models import Category, Entry
from elephantblog.utils import entry_list_lookup_related
        from feincms.contents import RichTextContent
        from feincms.module.medialibrary.contents import MediaFileContent
    "YearArchiveView",
    "MonthArchiveView",
    "DayArchiveView",
    "DateDetailView",
    "CategoryArchiveIndexView",
)


PAGINATE_BY = getattr(settings, "BLOG_PAGINATE_BY", 10)


class ElephantblogMixin:
    """
    This mixin autodetects whether the blog is integrated through an
    ApplicationContent and automatically switches to inheritance2.0
    if that's the case.

    Additionally, it adds the view instance to the template context
    as ``view``.

    This requires at least FeinCMS v1.5.
    """

    entry_class = Entry

    def get_context_data(self, **kwargs):
        kwargs.update({"view": self})
        return super().get_context_data(**kwargs)

    def get_queryset(self):

# Path: elephantblog/models.py
# class Category(models.Model, translations.TranslatedObjectMixin):
#     """
#     Category is language-aware and connected to the Entry model via
#     a many to many relationship.
#     """
# 
#     ordering = models.SmallIntegerField(_("ordering"), default=0)
# 
#     objects = translations.TranslatedObjectManager()
# 
#     class Meta:
#         verbose_name = _("category")
#         verbose_name_plural = _("categories")
#         ordering = ["ordering"]
# 
#     def __str__(self):
#         try:
#             translation = self.translation
#         except models.ObjectDoesNotExist:
#             return gettext("Unnamed category")
# 
#         if translation:
#             return "%s" % translation
# 
#         return gettext("Unnamed category")
# 
# class Entry(Base, ContentModelMixin):
#     is_active = models.BooleanField(_("is active"), default=True, db_index=True)
#     is_featured = models.BooleanField(_("is featured"), default=False, db_index=True)
# 
#     title = models.CharField(_("title"), max_length=100)
#     slug = models.SlugField(_("slug"), max_length=100, unique_for_date="published_on")
#     author = models.ForeignKey(
#         getattr(settings, "AUTH_USER_MODEL", "auth.User"),
#         on_delete=models.CASCADE,
#         related_name="blogentries",
#         limit_choices_to={"is_staff": True},
#         verbose_name=_("author"),
#     )
#     published_on = models.DateTimeField(
#         _("published on"),
#         blank=True,
#         null=True,
#         default=timezone.now,
#         db_index=True,
#         help_text=_("Will be filled in automatically when entry gets published."),
#     )
#     last_changed = models.DateTimeField(_("last change"), auto_now=True, editable=False)
# 
#     categories = models.ManyToManyField(
#         Category, verbose_name=_("categories"), related_name="blogentries", blank=True
#     )
# 
#     objects = EntryManager()
# 
#     class Meta:
#         get_latest_by = "published_on"
#         ordering = ["-published_on"]
#         verbose_name = _("entry")
#         verbose_name_plural = _("entries")
# 
#     def __str__(self):
#         return self.title
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self._old_is_active = self.is_active
# 
#     def save(self, *args, **kwargs):
#         if self.is_active and not self.published_on:
#             self.published_on = timezone.now()
# 
#         super().save(*args, **kwargs)
# 
#     save.alters_data = True
# 
#     def get_absolute_url(self):
#         # The view/template layer always works with visitors' local time.
#         # Therefore, also generate localtime URLs, otherwise visitors will
#         # hit 404s on blog entry URLs generated for them. Unfortunately, this
#         # also means that you cannot send a permalink around half the globe
#         # and expect it to work...
#         # https://code.djangoproject.com/ticket/18794
#         if settings.USE_TZ:
#             pub_date = timezone.localtime(self.published_on)
#         else:
#             pub_date = self.published_on
# 
#         return reverse(
#             "elephantblog_entry_detail",
#             kwargs={
#                 "year": pub_date.strftime("%Y"),
#                 "month": pub_date.strftime("%m"),
#                 "day": pub_date.strftime("%d"),
#                 "slug": self.slug,
#             },
#         )
# 
#     @classmethod
#     def register_extension(cls, register_fn):
#         from .modeladmins import EntryAdmin
# 
#         register_fn(cls, EntryAdmin)
# 
# Path: elephantblog/utils.py
# def entry_list_lookup_related(entry_qs):
#     LookupClass.lookup(entry_qs)


# Path: elephantblog/views.py
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core import paginator
from django.core.exceptions import FieldDoesNotExist
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.utils.translation import get_language
from django.views.generic import dates
from feincms.module.mixins import ContentObjectMixin
from elephantblog.models import Category, Entry
from elephantblog.utils import entry_list_lookup_related
        from feincms.contents import RichTextContent
        from feincms.module.medialibrary.contents import MediaFileContent

    "YearArchiveView",
    "MonthArchiveView",
    "DayArchiveView",
    "DateDetailView",
    "CategoryArchiveIndexView",
)


PAGINATE_BY = getattr(settings, "BLOG_PAGINATE_BY", 10)


class ElephantblogMixin:
    """
    This mixin autodetects whether the blog is integrated through an
    ApplicationContent and automatically switches to inheritance2.0
    if that's the case.

    Additionally, it adds the view instance to the template context
    as ``view``.

    This requires at least FeinCMS v1.5.
    """

    entry_class = Entry

    def get_context_data(self, **kwargs):
        kwargs.update({"view": self})
        return super().get_context_data(**kwargs)

    def get_queryset(self):

        return self.entry_class.objects.active().transform(entry_list_lookup_related)